I am currently writing selenium webdriver tests for a product that utilizes turbolinks (in ruby). When I click a button I have to wait for turbolinks to work. When I test jQuery callbacks I typically wait on my code with:
driver.execute_script 'return jQuery.active == 0'
What can I check via Javascript to verify that Turbolinks is done? Or is there an element I can grab to that can do the same? I see a progress bar on top but I can't find the element anywhere.
EDIT:
I'm able to do something like this:
driver.execute_script "$(document).on('page:load', function () { window.turbolinks = true; });"
driver.execute_script "$(document).on('page:before-change', function () { window.turbolinks = false; });"
on page load and then I can wait on window.turbolinks to be true
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.until { driver.execute_script 'return window.turbolinks;' }
Is there a better way of handling this?