Skip to content

[dotnet] Upgrade examples to selenium 4.41#2588

Open
nvborisenko wants to merge 2 commits intoSeleniumHQ:trunkfrom
nvborisenko:dotnet-4.41
Open

[dotnet] Upgrade examples to selenium 4.41#2588
nvborisenko wants to merge 2 commits intoSeleniumHQ:trunkfrom
nvborisenko:dotnet-4.41

Conversation

@nvborisenko
Copy link
Member

@nvborisenko nvborisenko commented Feb 20, 2026

User description

Selenium v4.41 has small breaking changes for SeleniumManager and DriverFinder. Both have more robust public API.

Description

Motivation and Context

Actualize examples.

Types of changes

  • Change to the site (I have double-checked the Netlify deployment, and my changes look good)
  • Code example added (and I also added the example to all translated languages)
  • Improved translation
  • Added new translation (and I also added a notice to each document missing translation)

Checklist

  • I have read the contributing document.
  • I have used hugo to render the site/docs locally and I am sure it works.

PR Type

Enhancement


Description

  • Upgrade Selenium WebDriver NuGet packages from 4.38.0 to 4.41.0

  • Update DevTools API references from V142 to V145

  • Convert DriverFinder methods to async with new API

  • Add System.Threading.Tasks imports for async support


Diagram Walkthrough

flowchart LR
  A["Selenium 4.38.0"] -- "upgrade packages" --> B["Selenium 4.41.0"]
  C["DevTools V142"] -- "update API version" --> D["DevTools V145"]
  E["Sync DriverFinder methods"] -- "convert to async" --> F["Async DriverFinder methods"]
  B --> G["Updated Examples"]
  D --> G
  F --> G
Loading

File Walkthrough

Relevant files
Dependencies
SeleniumDocs.csproj
Upgrade Selenium NuGet packages to 4.41.0                               

examples/dotnet/SeleniumDocs/SeleniumDocs.csproj

  • Updated Selenium.Support package from 4.38.0 to 4.41.0
  • Updated Selenium.WebDriver package from 4.38.0 to 4.41.0
+2/-2     
Enhancement
NetworkTest.cs
Update DevTools API from V142 to V145                                       

examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs

  • Updated DevTools imports from V142 to V145
  • Updated GetVersionSpecificDomains calls to use V145 API
  • Updated EnableCommandSettings references to V145 namespace
+6/-6     
ChromeTest.cs
Convert Chrome browser location methods to async                 

examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs

  • Added System.Threading.Tasks import for async support
  • Converted SetBrowserLocation() method to async Task
  • Converted GetChromeLocation() to GetChromeLocationAsync() with async
    implementation
  • Updated DriverFinder.GetBrowserPath() to GetBrowserPathAsync() with
    await
+5/-4     
EdgeTest.cs
Convert Edge browser location methods to async                     

examples/dotnet/SeleniumDocs/Browsers/EdgeTest.cs

  • Added System.Threading.Tasks import for async support
  • Converted SetBrowserLocation() method to async Task
  • Converted GetEdgeLocation() to GetEdgeLocationAsync() with async
    implementation
  • Updated DriverFinder.GetBrowserPath() to GetBrowserPathAsync() with
    await
+5/-4     
FirefoxTest.cs
Convert Firefox browser location methods to async               

examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs

  • Added System.Threading.Tasks import for async support
  • Converted SetBinary() method to async Task
  • Converted GetFirefoxLocation() to GetFirefoxLocationAsync() with async
    implementation
  • Updated DriverFinder.GetBrowserPath() to GetBrowserPathAsync() with
    await
+5/-4     
ServiceTest.cs
Convert driver location method to async                                   

examples/dotnet/SeleniumDocs/Drivers/ServiceTest.cs

  • Added System.Threading.Tasks import for async support
  • Converted DriverLocation() method to async Task
  • Converted GetDriverLocation() to GetDriverLocationAsync() with async
    implementation
  • Updated DriverFinder.GetDriverPath() to GetDriverPathAsync() with
    await
+5/-4     
LoggingTest.cs
Update imports for Selenium 4.41 API                                         

examples/dotnet/SeleniumDocs/Troubleshooting/LoggingTest.cs

  • Removed unused OpenQA.Selenium import
  • Added OpenQA.Selenium.Manager import for new API
+1/-1     

@netlify
Copy link

netlify bot commented Feb 20, 2026

Deploy Preview for selenium-dev ready!

Name Link
🔨 Latest commit 4e2f512
🔍 Latest deploy log https://app.netlify.com/projects/selenium-dev/deploys/699e36ca61f295000869f965
😎 Deploy Preview https://deploy-preview-2588--selenium-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Feb 20, 2026

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Feb 20, 2026

PR Code Suggestions ✨

Latest suggestions up to 4e2f512

CategorySuggestion                                                                                                                                    Impact
Possible issue
Ensure custom tests run reliably

Revert the DriverLocation test method to be synchronous (void) and use
.GetAwaiter().GetResult() to block on the async call, ensuring compatibility
with the TestMethodCustom attribute.

examples/dotnet/SeleniumDocs/Drivers/ServiceTest.cs [19-27]

 [TestMethodCustom]
 [EnabledOnOs("OSX")]
-public async Task DriverLocation()
+public void DriverLocation()
 {
     var options = GetLatestChromeOptions();
-    var service = ChromeDriverService.CreateDefaultService(await GetDriverLocationAsync(options));
+    var driverLocation = GetDriverLocationAsync(options).GetAwaiter().GetResult();
+    var service = ChromeDriverService.CreateDefaultService(driverLocation);
 
     driver = new ChromeDriver(service, options);
 }
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a potential issue where a custom test attribute TestMethodCustom may not support async Task, proposing a robust synchronous blocking pattern to prevent unreliable test execution.

Medium
General
Prevent temp directory leaks

Wrap the logic in SetBrowserLocation in a try/catch block to ensure the
temporary userDataDir directory is deleted if an exception occurs during driver
initialization, preventing resource leaks.

examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs [46-59]

 [TestMethod]
 public async Task SetBrowserLocation()
 {
     string userDataDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
     Directory.CreateDirectory(userDataDir);
-    var options = new ChromeOptions();
-    options.AddArgument($"--user-data-dir={userDataDir}");
-    options.AddArgument("--no-sandbox");
-    options.AddArgument("--disable-dev-shm-usage");
 
-    options.BinaryLocation = await GetChromeLocationAsync();
+    try
+    {
+        var options = new ChromeOptions();
+        options.AddArgument($"--user-data-dir={userDataDir}");
+        options.AddArgument("--no-sandbox");
+        options.AddArgument("--disable-dev-shm-usage");
 
-    driver = new ChromeDriver(options);
+        options.BinaryLocation = await GetChromeLocationAsync();
+
+        driver = new ChromeDriver(options);
+    }
+    catch
+    {
+        if (Directory.Exists(userDataDir))
+        {
+            Directory.Delete(userDataDir, recursive: true);
+        }
+        throw;
+    }
 }
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies a resource leak (temporary directory) on exceptions and proposes a try/catch block to handle cleanup, which improves the test's robustness.

Low
  • More

Previous suggestions

Suggestions up to commit 676da4d
CategorySuggestion                                                                                                                                    Impact
Possible issue
Align DevTools startup version

Update the DevTools version in the Startup method from "142" to "145" to align
with the updated V145 imports.

examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs [17-20]

 public void Startup()
 {
-    StartDriver("142");
+    StartDriver("145");
 }
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical version mismatch between the driver initialization (142) and the DevTools API usage (V145), which would cause test failures.

High

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants