[英]Why do I get undefined method `click' for Cucumber::Rails::World ? in Cucumber / Capybara steps
我可以得到其他的水豚方法,如訪問,fill_in,選擇等..工作。 但不是點擊
Given /^a no fee license called "([^"]*)"$/ do |arg1|
@l = FactoryGirl.create(:license,
name: arg1)
end
When /^execute the license$/ do
visit(license_path(@l))
click('Execute License')
end
錯誤:
Scenario: no fee license is executed # features/visitor_no_fee_license.feature:14
When I fill out the licensee info with valid info # features/step_definitions/licenses_steps.rb:21
And execute the license # features/step_definitions/licenses_steps.rb:35
undefined method `click' for #<Cucumber::Rails::World:0x007feebad4dec8> (NoMethodError)
./features/step_definitions/licenses_steps.rb:37:in `/^execute the license$/'
features/visitor_no_fee_license.feature:16:in `And execute the license'
Capybara的DSL改變了。 如果您現在不知道它是鏈接還是按鈕,請使用click_on
而不是單擊。
也許你打算使用click_link ?
When /^(?:|I )follow "([^"]*)"$/ do |link|
click_link(link)
end
如果這些都不適合您的需求,那么您可以調用點擊元素。
When /^(?:|I )click "([^"]*)" span$/ do |selector|
element ||= find('span', :text => selector)
element.click
end
如果以上都不是有用的,那么這里是所有點擊方法的列表,如果你確定了你想要使用的方法,我可以進一步提供幫助。
http://rubydoc.info/search/github/jnicklas/capybara/master?q=click
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.