Created
March 2, 2017 00:09
-
-
Save bjeanes/3aa9c29b87030c7e527feacb217b97d5 to your computer and use it in GitHub Desktop.
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
# Chromedriver has this annoying bug where when trying to click a button or | |
# something which is obscured by another element due to scrolling, it fails to | |
# click the button or link. | |
# | |
# This is a workaround to always scroll the element into view after finding it. | |
module Capybara | |
module Chrome | |
module Finders | |
def find(*args) | |
super(*args).tap do |node| | |
if Capybara::Selenium::Driver === (driver = Capybara.current_session.driver) | |
if (browser = driver.browser).browser.to_s =~ /chrome/ | |
browser.execute_script('arguments[0].scrollIntoView(false);', node.native) | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
Capybara::Node::Base.send :include, Capybara::Chrome::Finders |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment