简体   繁体   English

为什么我为Cucumber :: Rails :: World获取未定义的方法`click'? 在Cucumber / Capybara的步骤

[英]Why do I get undefined method `click' for Cucumber::Rails::World ? in Cucumber / Capybara steps

I can get other capybara methods like visit, fill_in, select etc.. to work. 我可以得到其他的水豚方法,如访问,fill_in,选择等..工作。 but not click 但不是点击

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

error: 错误:

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's DSL changed. Capybara的DSL改变了。 Use click_on instead of click, if you don't know if it's a link or a button now. 如果您现在不知道它是链接还是按钮,请使用click_on而不是单击。

https://github.com/jnicklas/capybara/blob/549e67336c712a1ef2119ce5ff64dbbc7542480f/lib/capybara/session.rb https://github.com/jnicklas/capybara/blob/549e67336c712a1ef2119ce5ff64dbbc7542480f/lib/capybara/session.rb

Perhaps you meant to use click_link ? 也许你打算使用click_link

When /^(?:|I )follow "([^"]*)"$/ do |link|
  click_link(link)
end

There is also click_button 还有click_button

If neither of these suit your needs, then you can call click on an element. 如果这些都不适合您的需求,那么您可以调用点击元素。

When /^(?:|I )click "([^"]*)" span$/ do |selector|
  element ||= find('span', :text => selector)
  element.click
end

If none of the above is helpful, then here are a list of all the click methods, if you identify the one you wish to use, I may be able to assist further. 如果以上都不是有用的,那么这里是所有点击方法的列表,如果你确定了你想要使用的方法,我可以进一步提供帮助。

http://rubydoc.info/search/github/jnicklas/capybara/master?q=click http://rubydoc.info/search/github/jnicklas/capybara/master?q=click

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 滑轨| 黄瓜 水豚| click_button生成GET请求 - Rails | Cucumber | Capybara | click_button generates GET request 未定义的局部变量或方法&#39;page&#39;的Cucumber :: Rails :: World(NameError) - Undefined local variable or method 'page' for Cucumber::Rails::World (NameError) 当使用Capybara和Cucumber时,未定义的方法&#39;应该&#39; - Undefined method 'should' when using Capybara with Cucumber 如何在Rails 3中使用Cucumber / Capybara在页面上找到图像 - How do I find an image on a page with Cucumber / Capybara in Rails 3 我可以使用Selenium IDE生成Cucumber / Capybara步骤吗? - Can I use Selenium IDE to generate Cucumber/Capybara steps? Rails应用:@javascript Selenium Cucumber / Capybara测试失败,对象未定义 - Rails app: @javascript Selenium Cucumber/Capybara tests fail with object Undefined #的未定义方法`find_link&#39; <Cucumber::Rails::World:0x818e02e8> (NoMethodError) - undefined method `find_link' for #<Cucumber::Rails::World:0x818e02e8> (NoMethodError) Rails,Cucumber,Capybara:会话不会持续存在 - Rails, Cucumber, Capybara: session is not persisted Rails 5.0.1 中的 Capybara Cucumber 超时 - Capybara Cucumber timeout with Rails 5.0.1 Rails服务器不是以黄瓜/水豚开头的 - rails server not starting with cucumber/capybara
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM