From 676da4d71c53c1e1f1fefc99254fe5b5b91a6012 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 20 Feb 2026 13:11:41 +0300 Subject: [PATCH] [dotnet] Upgrade examples to selenium 4.41 --- examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs | 12 ++++++------ examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs | 9 +++++---- examples/dotnet/SeleniumDocs/Browsers/EdgeTest.cs | 9 +++++---- examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs | 9 +++++---- examples/dotnet/SeleniumDocs/Drivers/ServiceTest.cs | 9 +++++---- examples/dotnet/SeleniumDocs/SeleniumDocs.csproj | 4 ++-- .../SeleniumDocs/Troubleshooting/LoggingTest.cs | 2 +- 7 files changed, 29 insertions(+), 25 deletions(-) diff --git a/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs b/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs index 2bec43fe39bd..bd1f950cc200 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/CDP/NetworkTest.cs @@ -4,8 +4,8 @@ using OpenQA.Selenium; using OpenQA.Selenium.DevTools; using System.Linq; -using OpenQA.Selenium.DevTools.V142.Network; -using OpenQA.Selenium.DevTools.V142.Performance; +using OpenQA.Selenium.DevTools.V145.Network; +using OpenQA.Selenium.DevTools.V145.Performance; namespace SeleniumDocs.BiDi.CDP @@ -109,9 +109,9 @@ public async Task PerformanceMetrics() driver.Url = "https://www.selenium.dev/selenium/web/frameset.html"; var session = ((IDevTools)driver).GetDevToolsSession(); - var domains = session.GetVersionSpecificDomains(); + var domains = session.GetVersionSpecificDomains(); - await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V142.Performance.EnableCommandSettings()); + await domains.Performance.Enable(new OpenQA.Selenium.DevTools.V145.Performance.EnableCommandSettings()); var metricsResponse = await session.SendCommand( new GetMetricsCommandSettings() @@ -130,8 +130,8 @@ await session.SendCommand( public async Task SetCookie() { var session = ((IDevTools)driver).GetDevToolsSession(); - var domains = session.GetVersionSpecificDomains(); - await domains.Network.Enable(new OpenQA.Selenium.DevTools.V142.Network.EnableCommandSettings()); + var domains = session.GetVersionSpecificDomains(); + await domains.Network.Enable(new OpenQA.Selenium.DevTools.V145.Network.EnableCommandSettings()); var cookieCommandSettings = new SetCookieCommandSettings { diff --git a/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs b/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs index 3bd8cc32935d..7e0e6fecfdb0 100644 --- a/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs +++ b/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using System.Text.RegularExpressions; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; @@ -43,7 +44,7 @@ public void Arguments() } [TestMethod] - public void SetBrowserLocation() + public async Task SetBrowserLocation() { string userDataDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Directory.CreateDirectory(userDataDir); @@ -52,7 +53,7 @@ public void SetBrowserLocation() options.AddArgument("--no-sandbox"); options.AddArgument("--disable-dev-shm-usage"); - options.BinaryLocation = GetChromeLocation(); + options.BinaryLocation = await GetChromeLocationAsync(); driver = new ChromeDriver(options); } @@ -157,13 +158,13 @@ private string GetLogLocation() return _logLocation; } - private static string GetChromeLocation() + private static async Task GetChromeLocationAsync() { var options = new ChromeOptions { BrowserVersion = "stable" }; - return new DriverFinder(options).GetBrowserPath(); + return await new DriverFinder(options).GetBrowserPathAsync(); } } } diff --git a/examples/dotnet/SeleniumDocs/Browsers/EdgeTest.cs b/examples/dotnet/SeleniumDocs/Browsers/EdgeTest.cs index 7eb9a7145b3c..72061502a4b8 100644 --- a/examples/dotnet/SeleniumDocs/Browsers/EdgeTest.cs +++ b/examples/dotnet/SeleniumDocs/Browsers/EdgeTest.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using System.Text.RegularExpressions; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; using OpenQA.Selenium.Chromium; @@ -43,11 +44,11 @@ public void Arguments() } [TestMethod] - public void SetBrowserLocation() + public async Task SetBrowserLocation() { var options = new EdgeOptions(); - options.BinaryLocation = GetEdgeLocation(); + options.BinaryLocation = await GetEdgeLocationAsync(); driver = new EdgeDriver(options); } @@ -151,13 +152,13 @@ private string GetLogLocation() return _logLocation; } - private static string GetEdgeLocation() + private static async Task GetEdgeLocationAsync() { var options = new EdgeOptions { BrowserVersion = "stable" }; - return new DriverFinder(options).GetBrowserPath(); + return await new DriverFinder(options).GetBrowserPathAsync(); } } } \ No newline at end of file diff --git a/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs b/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs index cc017217f410..54309a2b9749 100644 --- a/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs +++ b/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; @@ -48,11 +49,11 @@ public void Arguments() } [TestMethod] - public void SetBinary() + public async Task SetBinary() { var options = new FirefoxOptions(); - options.BinaryLocation = GetFirefoxLocation(); + options.BinaryLocation = await GetFirefoxLocationAsync(); driver = new FirefoxDriver(options); } @@ -197,13 +198,13 @@ private void SetWaitingDriver() driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2); } - private static string GetFirefoxLocation() + private static async Task GetFirefoxLocationAsync() { var options = new FirefoxOptions() { BrowserVersion = "stable" }; - return new DriverFinder(options).GetBrowserPath(); + return await new DriverFinder(options).GetBrowserPathAsync(); } private void ResetGlobalLog() diff --git a/examples/dotnet/SeleniumDocs/Drivers/ServiceTest.cs b/examples/dotnet/SeleniumDocs/Drivers/ServiceTest.cs index 4aad3970c97b..799f116c29c7 100644 --- a/examples/dotnet/SeleniumDocs/Drivers/ServiceTest.cs +++ b/examples/dotnet/SeleniumDocs/Drivers/ServiceTest.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; @@ -17,10 +18,10 @@ public void BasicService() [TestMethodCustom] [EnabledOnOs("OSX")] - public void DriverLocation() + public async Task DriverLocation() { var options = GetLatestChromeOptions(); - var service = ChromeDriverService.CreateDefaultService(GetDriverLocation(options)); + var service = ChromeDriverService.CreateDefaultService(await GetDriverLocationAsync(options)); driver = new ChromeDriver(service, options); } @@ -34,9 +35,9 @@ public void DriverPort() driver = new ChromeDriver(service); } - private static string GetDriverLocation(ChromeOptions options) + private static async Task GetDriverLocationAsync(ChromeOptions options) { - return new DriverFinder(options).GetDriverPath(); + return await new DriverFinder(options).GetDriverPathAsync(); } private static ChromeOptions GetLatestChromeOptions() diff --git a/examples/dotnet/SeleniumDocs/SeleniumDocs.csproj b/examples/dotnet/SeleniumDocs/SeleniumDocs.csproj index 08582d0ea2b0..a2ede51dc128 100644 --- a/examples/dotnet/SeleniumDocs/SeleniumDocs.csproj +++ b/examples/dotnet/SeleniumDocs/SeleniumDocs.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/examples/dotnet/SeleniumDocs/Troubleshooting/LoggingTest.cs b/examples/dotnet/SeleniumDocs/Troubleshooting/LoggingTest.cs index b4b4247eb4b1..2b63fca28e65 100644 --- a/examples/dotnet/SeleniumDocs/Troubleshooting/LoggingTest.cs +++ b/examples/dotnet/SeleniumDocs/Troubleshooting/LoggingTest.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using OpenQA.Selenium; using OpenQA.Selenium.Internal.Logging; +using OpenQA.Selenium.Manager; using OpenQA.Selenium.Remote; using System; using System.IO;