I am currently writing selenium webdriver tests for a product that uses turbolinks (in ruby). When I press the button, I have to wait for the turbine to work. When I test jQuery callbacks, I usually expect from my code with:
driver.execute_script 'return jQuery.active == 0'
What can I check with Javascript to check what Turbolinks are? Or is there an element that I can capture to do the same? I see a progress bar at the top, but I cannot find the item anywhere.
EDIT:
I can 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; });"
when the page loads, and then I can wait for 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 to handle this?
source
share