Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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

raid5 commented Aug 27, 2011

I still seem to have this issue with this patch :(

raid5 commented Aug 28, 2011

I noticed the latest selenium driver version changed the error to Selenium::WebDriver::Error::InvalidSelectorError

Owner

skiz commented Aug 28, 2011

Hrrmmm... still working for us. I'l try out the latest driver and report back

khelal commented Sep 5, 2011

Sorry for the really newbie question, but trying this patch with cucumber and getting this error:

/Users/khelal/Sites/monaqasat.com/2.0/features/support/capybara/selenium/driver.rb:4
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/gems/cucumber-1.0.0/bin/../lib/cucumber/rb_support/rb_language.rb:143:in `load_code_file'
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/gems/cucumber-1.0.0/bin/../lib/cucumber/runtime/support_code.rb:176:in `load_file'
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/gems/cucumber-1.0.0/bin/../lib/cucumber/runtime/support_code.rb:78:in `load_files!'
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/gems/cucumber-1.0.0/bin/../lib/cucumber/runtime/support_code.rb:77:in `each'
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/gems/cucumber-1.0.0/bin/../lib/cucumber/runtime/support_code.rb:77:in `load_files!'
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/gems/cucumber-1.0.0/bin/../lib/cucumber/runtime.rb:137:in `load_step_definitions'
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/gems/cucumber-1.0.0/bin/../lib/cucumber/runtime.rb:39:in `run!'
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/gems/cucumber-1.0.0/bin/../lib/cucumber/cli/main.rb:43:in `execute!'
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/gems/cucumber-1.0.0/bin/../lib/cucumber/cli/main.rb:20:in `execute'
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/gems/cucumber-1.0.0/bin/cucumber:14
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/bin/cucumber:19:in `load'
/Users/khelal/.rvm/gems/ree-1.8.7-2011.03@monaqasat3/bin/cucumber:19

Can you help? :(

Owner

skiz commented Sep 5, 2011

@khelal I haven't tried this patch with cucumber, only selenium based integration specs. Hopefully this will be fixed upstream soon!

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..

Owner

skiz commented Sep 5, 2011

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

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