简体   繁体   中英

undefined method `invalid_element_errors' in capybara-webkit

first off I'd like to point out that I'm a bit new at this and thus hope this post will be understandable.

Gems:
  rails (2.3.11
  nokogiri (1.5.4)
  cucumber (1.1.9)
  capybara (1.1.2)
  copybara-webkit (0.12.1)

Right now I'm doing a project were I'm trying to use cucumber for integration testing of a rails web application. Since the web-application relies heavily on javascript and ajax I want to use a capybara driver that can handle this. (I just realized :rake_test does not) But I don't want to have a browser window pop up all the time as that will take time. So I opted on capybara-webkit. But now that I changed driver, by setting the javascript driver for capybara in my env.rb, I keep getting a annoying error all the time:

    undefined method `invalid_element_errors' for #<Capybara::Driver::Webkit:0x9c50bf8> (NoMethodError)
  ./features/step_definitions/some_steps.rb:37

My code at that line:

    >> 35  select("something", :from => find("select[class='class_name']")[:id])
    >> 36  click_link('javascript_link')
    >> 37  click_link('another_javascript_link')

I'm using a find in line 35 since the id is dynamic. Now it seems like the problem is actually the find method since if I add another find with known id above this point I'm getting the same error thrown on me on that line instead.

How do I get rid of this problem so I can use capybara-webkit? I've heard somewhere that this is a problem in the actual driver and that a fix is available at the github masterbranch and that you somehow can link your gem there? If so can anybody explain how to do it?

I've suffered this problem too. It's a capybara-webkit bug: the 0.12.1 version does not have the invalid_element_errors method.

There was a pull request a few months ago with the fix, but it wasn't merged (https://github.com/thoughtbot/capybara-webkit/pull/288). Now they have added the method in the master branch, so you have to use the git repository:

gem 'capybara-webkit', :git => 'git://github.com/thoughtbot/capybara-webkit'

Try it and see if it works for you :).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM