Skip to content

Introduce raise_on_unhandled_modal browser configuration - #320

Closed
seanpdoyle wants to merge 1 commit into
rubycdp:mainfrom
seanpdoyle:raise_on_unhandled_modal
Closed

Introduce raise_on_unhandled_modal browser configuration#320
seanpdoyle wants to merge 1 commit into
rubycdp:mainfrom
seanpdoyle:raise_on_unhandled_modal

Conversation

@seanpdoyle

Copy link
Copy Markdown
Contributor

The problem

When executing a system test suite that relies on confirm, prompt, or other browser-level modals, the default behavior to ignore modally presented dialogs can cause false negatives.

For example, a change to the implementation might accidentally introduce a perpetually prompting confirmation modal. While the test suite outputs "Modal window … has been opened" warnings, the underlying test still passes.

The proposal

This commit proposes a new Cuprite-level :raise_on_unhandled_modal option to control whether an unhandled modal warns, or raises. When set to true, then false negative test would fail, rather than pass.

@seanpdoyle
seanpdoyle force-pushed the raise_on_unhandled_modal branch 3 times, most recently from c6b499d to 95bff0e Compare July 23, 2026 18:54
The problem
---

When executing a system test suite that relies on `confirm`, `prompt`,
or other browser-level modals, the default behavior to ignore modally
presented dialogs can cause false negatives.

For example, a change to the implementation might accidentally introduce
a perpetually prompting confirmation modal. While the test suite outputs
"Modal window … has been opened" warnings, the underlying test still
passes.

The proposal
---

This commit proposes a new Cuprite-level `:raise_on_unhandled_modal`
option to control whether an unhandled modal warns, or raises. When set
to `true`, then false negative test would fail, rather than pass.
@seanpdoyle
seanpdoyle force-pushed the raise_on_unhandled_modal branch from 95bff0e to 1692d8d Compare July 23, 2026 19:21
@route

route commented Aug 25, 2026

Copy link
Copy Markdown
Member

Superseded by #324, which carries this commit forward rebased onto current main, plus a fix for two issues found in review:

  • Browser#initialize mutated the caller's options hash with delete instead of dig, so Driver#reset! (called between every Capybara example) always saw the option as absent and forced it back to false after the very first use — the option never actually took effect via normal driver configuration.
  • Raising directly from the Page.javascriptDialogOpening handler doesn't work: that callback runs on Ferrum's background CDP dispatcher thread, so the exception never reaches the caller and permanently kills that thread, wedging the browser for the rest of the suite (reproduced: it cascades into unrelated failures in later examples). Introduce raise_on_unhandled_modal browser configuration #324 defers the raise to the main thread's next command instead, and raises a proper Capybara::Cuprite::UnhandledModalError rather than a bare RuntimeError.

Closing this in favor of #324.

@route route closed this Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants