Open lnsight opened 5 years ago
Please can you write a test to reproduce this issue, or better yet, create a PR.
We recently encount same error but can't reproduce manually... @lnsight Can you share your patch?
Patch for capybara 3.15.0:
module CapybaraShotOnTimedOutSessionReset
def wait_for_empty_page(timer)
until find_xpath('/html/body/*').empty?
if timer.expired?
timestamp = Time.current.strftime('%y-%m-%d-%H-%M-%S')
file_path = File.join(Capybara.save_path, "timed_out_session_reset_#{timestamp}.png")
save_screenshot(file_path) # rubocop:disable Lint/Debugger
end
raise Capybara::ExpectationNotMet, 'Timed out waiting for Selenium session reset' if timer.expired?
sleep 0.01
# It has been observed that it is possible that asynchronous JS code in
# the application under test can navigate the browser away from about:blank
# if the timing is just right. Ensure we are still at about:blank...
@browser.navigate.to('about:blank') unless current_url == 'about:blank'
end
end
end
Capybara::Selenium::Driver.prepend(CapybaraShotOnTimedOutSessionReset) if ENV['CAPYBARA_EXTRA_SHOT']
Please can you write a test to reproduce this issue, or better yet, create a PR.
I'm not reproduced an issue yet because this error appears randomly. In our system it's occurs on ajax response after browser session cleanup (authorization popup prevents redirect to blank page).
@lnsight Thanks!
I had to patch Capybara::Selenium::Driver#wait_for_empty_page for that.