During my automation process, I am checking for the completion of
document.readyState === 'complete'
and also monitoring a local variable known as window.renderComplete
(which indicates when the server has finished rendering the page).
However, there seems to be an issue where the comparison
Capybara.current_session.driver.browser.title == title
is failing initially for a few iterations before eventually passing after approximately 10 loops. This disrupts the flow of the loop.
I am curious if there is a specific delay between the browser receiving all the data and setting it into variables. Could this be a limitation within Capybara? It's puzzling why there might still be a delay in the browser even when both readyState and renderComplete are confirmed to be true.
renderComplete = page.evaluate_script("(window.renderComplete == true) && (document.readyState === 'complete');")
if renderComplete
puts "pass 1"
else
loop do
renderComplete = page.evaluate_script("window.renderComplete == true;")
break if renderComplete == true
end
puts "pass 2"
end
browser = Capybara.current_session.driver.browser
Timeout::timeout(Capybara.default_max_wait_time) do
i=1
loop do
puts "loop! #{i}"
i+=1
break if title == browser.title
end
end
assert_equal title, browser.title