Skip to content

Instantly share code, notes, and snippets.

@ematta
Last active December 19, 2019 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ematta/bc0d1e68e0144efeb777 to your computer and use it in GitHub Desktop.
Save ematta/bc0d1e68e0144efeb777 to your computer and use it in GitHub Desktop.
Turbolinks and Selenium Webdriver (Ruby)
driver.execute_script "$(document).on('page:load', function () { window.turbolink = true; });"
driver.execute_script "$(document).on('page:before-change', function () { window.turbolink = false; });"
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.until { driver.execute_script 'return window.turbolink;' }
@bergatron
Copy link

Hey, where in the test did you place this code?

@ubugnu
Copy link

ubugnu commented Dec 19, 2019

make it easy, using the rspec-wait gem, just wait for the progress bar to disappear:

And("I wait for turbolinks to load") do
  wait(30.seconds).for do
    page.has_selector?('.turbolinks-progress-bar')
  end.to be false
end

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