Skip to content

Instantly share code, notes, and snippets.

@semipermeable
Created October 17, 2011 22:22
Show Gist options
  • Save semipermeable/1294029 to your computer and use it in GitHub Desktop.
Save semipermeable/1294029 to your computer and use it in GitHub Desktop.
Monkeypatch to fix a race in Selenium-Webdriver
# features/support/selenium_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)
begin
browser.find_elements(:xpath, selector).map { |node| Capybara::Selenium::Node.new(self, node) }
rescue Selenium::WebDriver::Error::UnhandledError
sleep 1
browser.find_elements(:xpath, selector).map { |node| Capybara::Selenium::Node.new(self, node) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment