Created
October 17, 2011 22:22
-
-
Save semipermeable/1294029 to your computer and use it in GitHub Desktop.
Monkeypatch to fix a race in Selenium-Webdriver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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