用于使用水豚选择下拉列表:获取未定义的方法
[click_button' for nil:NilClass (NoMethodError) ./features/pages/cm_dash_board.rb:187:in
choose_role'./features/pages/cm_dash_board.rb:147:inset_role' ./features/step_definitions/cm_dash_board_steps.rb:58:in
/ ^
Method:
def choose_role(role_name)
click_button CHOOSE_ROLE
find(ROLEDROPDOWN).all('li').select{|role| role.text == role_name}.first.click_button
end
Feature file:And(/^I assign "([^"]*)" role to the "([^"]*)" user$/) do |email, role_name|
@sw.cm_dash_board.set_role(email,role_name)
end
select
,而应该在all
调用中指定它,例如find(ROLEDROPDOWN).find('li', exact_text: role_name).click_button
这可能仍然会失败,但是至少该错误会告诉您为什么会失败