Skip to content

Commit

Permalink
Fix sessions not working after error or unload alert popping up
Browse files Browse the repository at this point in the history
  • Loading branch information
GUI committed Feb 2, 2025
1 parent 1ddb041 commit 10a92ca
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,17 @@ def teardown
super

# Clear the session and logout after each test.
::Capybara.reset_sessions!
begin
::Capybara.reset_sessions!
rescue
# Resetting may fail since it navigates away from the page, which may
# trigger an extra `onbeforeunload` alert warning. Since this is not
# automatically handled (due to `unhandled_prompt_behavior`), trigger
# the internal mechanism to dismiss these unload alerts, and then try
# resetting again.
::Capybara.current_session.driver.send(:accept_unhandled_reset_alert)
retry
end

# Ensure the default driver is used again for future tests (for any
# tests that may have changed the driver).
Expand Down

0 comments on commit 10a92ca

Please sign in to comment.