Add test for UnhandledPromptBehavior in ChromeOptions#2611
Conversation
👷 Deploy request for selenium-dev pending review.Visit the deploys page to approve it
|
|
|
Review Summary by QodoAdd test for UnhandledPromptBehavior in ChromeOptions
WalkthroughsDescription• Add test method for UnhandledPromptBehavior option • Demonstrates setting DismissAndNotify behavior in ChromeOptions • Follows existing test pattern with driver initialization and cleanup Diagramflowchart LR
A["OptionsTest.cs"] -- "adds new test method" --> B["SetUnhandledPromptBehavior"]
B -- "sets UnhandledPromptBehavior" --> C["DismissAndNotify"]
C -- "creates ChromeDriver" --> D["Navigate and cleanup"]
File Changes1. examples/dotnet/SeleniumDocs/Drivers/OptionsTest.cs
|
Code Review by Qodo
1. Prompt behavior untested
|
Code Review by Qodo
1. Prompt behavior untested
|
|
@kimtg tests are failing in some environments. will come back with update on this later. |
|
@kimtg can you please sign the CLA? |
|
Superseeded by #2724 |
* Add C# example for unhandledPromptBehavior option Adds the missing SetUnhandledPromptBehavior test to OptionsTest.cs and wires the CSharp tab in the docs to it, replacing the placeholder badge. Based on #2611 and #2612 by kimtg. Co-authored-by: KIM Taegyoon <steloflute@gmail.com> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: avoid Windows file-lock races in EdgeTest log tests On Windows, msedgedriver can still hold its log file open for a moment after driver.Quit(), so reading the log right after Quit() intermittently threw IOException in LogsToFile, LogsLevel, ConfigureDriverLogs, and DisableBuildCheck. Mirrors the Python and Ruby examples, which read the log while the service is still running instead of after quitting (see 4decac3 for the equivalent Python fix). Also guards the log file deletion in Cleanup() against the same race, tolerating IOException like Python's contextlib.suppress(OSError) and Ruby's FileUtils.rm_f. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: retry reading Edge log file to survive Windows lock window CI showed the log file is locked for the entire life of the Edge driver service on Windows, not just briefly after Quit() -- moving the read before Quit() (previous commit) failed immediately since the driver process was still running. Reading after Quit() is correct, but the OS still needs a moment to release the handle once the process exits, so wrap the read in a short bounded retry instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: null-safe driver.Quit() in EdgeTest cleanup If driver creation throws before the field is assigned, Cleanup()'s unconditional driver.Quit() throws NullReferenceException and masks the real test failure. ChromeTest.cs already uses this driver?.Quit() pattern in its own cleanup; apply it here too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: widen retry budget for Edge log file read on Windows The previous 2s retry budget (10 x 200ms) wasn't enough -- CI still failed with the same IOException after exhausting all attempts. EdgeDriverService.LogPath is fed by DriverService's async OutputDataReceived event handler (per the Selenium.WebDriver XML docs), so the log FileStream can stay open for several seconds after Quit() returns while the last buffered output drains. Widen the budget to ~9.5s (20 x 500ms) to reliably outlast that tail. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix: narrow EdgeTest log retry to sharing/lock violations only ReadLogLines was retrying on any IOException, so a genuine failure (missing file, bad path, permissions) would silently eat up to ~10s of sleeping before surfacing, slowing down and obscuring real failures. Restrict the retry to the specific Win32 sharing/lock violation HRESULTs the Windows file-lock race actually produces; everything else propagates immediately. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * try: replace log-read retry with explicit service.Dispose() Drop the retry loop and try forcing a real synchronous teardown instead: EdgeDriverService.LogPath is fed by DriverService's async OutputDataReceived handler, so driver.Quit() alone may return before that stream is fully flushed and closed. Holding the service reference and calling service.Dispose() explicitly should block until the log file is actually released, letting us read it with a plain File.ReadAllLines and no polling. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * revert: bring back narrowed retry, keep explicit service.Dispose() The explicit-Dispose-only approach didn't work: CI showed the same IOException immediately after driver.Quit() + service.Dispose(), so DriverService's async OutputDataReceived teardown isn't fully synchronous even through an explicit Dispose() call. Restore the retry (narrowed to actual sharing/lock-violation HRESULTs, ~9.5s budget), and keep the Dispose() call alongside it since it's still correct resource cleanup and may shrink the typical wait. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * simplify: drop HResult filtering and explanatory comments in EdgeTest This is a doc code example, not production code -- the narrowed sharing/lock-violation HResult check added unnecessary verbosity, and comments like "Close the Service log file before reading" get confusing once the file is translated. Keep the retry and service.Dispose(), drop the rest. --------- Co-authored-by: KIM Taegyoon <steloflute@gmail.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.
Description
Motivation and Context
Types of changes
Checklist