Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No screenshot on "Timed out waiting for Selenium session reset" error #258

Open
lnsight opened this issue Jun 10, 2019 · 5 comments
Open

Comments

@lnsight
Copy link

lnsight commented Jun 10, 2019

I had to patch Capybara::Selenium::Driver#wait_for_empty_page for that.

@mattheworiordan
Copy link
Owner

Please can you write a test to reproduce this issue, or better yet, create a PR.

@y-yagi
Copy link

y-yagi commented Jul 2, 2019

We recently encount same error but can't reproduce manually... @lnsight Can you share your patch?

@lnsight
Copy link
Author

lnsight commented Jul 8, 2019

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']

@lnsight
Copy link
Author

lnsight commented Jul 8, 2019

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).

@y-yagi
Copy link

y-yagi commented Jul 8, 2019

@lnsight Thanks!

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

No branches or pull requests

3 participants