Skip to content

Instantly share code, notes, and snippets.

@skiz
Created August 10, 2011 15:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skiz/1137135 to your computer and use it in GitHub Desktop.
Save skiz/1137135 to your computer and use it in GitHub Desktop.
MONKEY PATCH: Selenium::WebDriver::Error::UnhandledError (NS_ERROR_ILLEGAL_VALUE)
# File: spec/support/capybara_patch.rb
#
# This patch attempts to fix a race condition in the selenium web driver
# Reference: https://code.google.com/p/selenium/issues/detail?id=2099
class Capybara::Selenium::Driver
def find(selector)
browser.find_elements(:xpath, selector).map { |node| Capybara::Selenium::Node.new(self, node) }
rescue Selenium::WebDriver::Error::UnhandledError => e
e.message =~ /nsIDOMXPathEvaluator.createNSResolver/ ? retry : raise
end
end
@khelal
Copy link

khelal commented Sep 5, 2011

@skiz thx for fast reply and I hope so too. in the meantime, did you have to add a require anywhere in rspec to get it to load or was it automatic? i'm assuming (hoping) it must be the same thing with cucumber..

@skiz
Copy link
Author

skiz commented Sep 5, 2011

@khelal, I added it to spec/support which is automatically loaded when using rspec.

@khelal
Copy link

khelal commented Sep 5, 2011

@skiz: cool. just had a thought though. cucumber uses rspec right? so if i put it in rspec, it should also work for cucumber no? again, sorry if these are really stupid questions. that's what happens when a non-developer tries to fix something :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment