[dotnet] [bidi] Align SetDownloadBehavior command#17336
[dotnet] [bidi] Align SetDownloadBehavior command#17336nvborisenko merged 2 commits intoSeleniumHQ:trunkfrom
Conversation
Review Summary by QodoSimplify SetDownloadBehavior API with unified polymorphic method
WalkthroughsDescription• Consolidate three separate download behavior methods into single unified method • Accept flexible DownloadBehavior parameter instead of specific method overloads • Make DownloadBehavior types public with static Default property • Remove browser-specific test ignores and update tests to new API File Changes1. dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs
|
Code Review by Qodo
|
There was a problem hiding this comment.
Pull request overview
Refactors the .NET BiDi browser.setDownloadBehavior API to use a single polymorphic DownloadBehavior parameter, aligning call sites and related types with the unified command shape.
Changes:
- Consolidated multiple
SetDownloadBehavior*Asyncmethods intoSetDownloadBehaviorAsync(DownloadBehavior?)on the Browser module API. - Made
DownloadBehaviorand its derived records public, addingDownloadBehavior.Defaultas a “reset to default” alias. - Updated BiDi browser tests to use the consolidated method and new public types.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dotnet/test/webdriver/BiDi/Browser/BrowserTests.cs | Updates tests to use SetDownloadBehaviorAsync and the new DownloadBehavior* records. |
| dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs | Exposes DownloadBehavior records publicly and adds a Default alias for resetting behavior. |
| dotnet/src/webdriver/BiDi/Browser/IBrowserModule.cs | Replaces the previous method set with the consolidated SetDownloadBehaviorAsync API. |
| dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs | Implements the consolidated SetDownloadBehaviorAsync method and removes the specialized methods. |
Simplified polymorphic command parameters.
💥 What does this PR do?
This pull request refactors and simplifies the API for setting browser download behavior in the BiDi WebDriver implementation. The main change is consolidating multiple specific methods into a single, more flexible method that accepts a
DownloadBehaviorparameter. This also involves updating related interfaces, records, and tests to use the new approach.API Refactoring and Simplification:
SetDownloadBehaviorAllowedAsync,SetDownloadBehaviorDeniedAsync, and the overload for allowed with no path) into a single method:SetDownloadBehaviorAsync, which takes aDownloadBehaviorparameter. This provides a more flexible and unified API for setting download behavior. (dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs,dotnet/src/webdriver/BiDi/Browser/IBrowserModule.cs) [1] [2]DownloadBehaviorrecord and its derived types (DownloadBehaviorAllowed,DownloadBehaviorDenied) to be public, and added a staticDefaultproperty for clarity when resetting to default behavior. (dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs)Test Updates:
SetDownloadBehaviorAsyncmethod, including tests for allowed, denied, and default behaviors. Also added assertions for bothnullandDefaultusage. (dotnet/test/webdriver/BiDi/Browser/BrowserTests.cs)usingdirective for theOpenQA.Selenium.BiDi.Browsernamespace in the test file for clarity and correctness. (dotnet/test/webdriver/BiDi/Browser/BrowserTests.cs)🔄 Types of changes