From 8f725b3a80c3f3d621821e94a87db346ea91a8b1 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Wed, 20 Nov 2024 09:54:27 +0530 Subject: [PATCH] [dotnet] Add CDP deprecation warning for Firefox (#14759) Co-authored-by: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> --- dotnet/src/webdriver/Firefox/FirefoxDriver.cs | 1 + dotnet/src/webdriver/Remote/RemoteWebDriver.cs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/dotnet/src/webdriver/Firefox/FirefoxDriver.cs b/dotnet/src/webdriver/Firefox/FirefoxDriver.cs index da3061c897d8b..99f9cb3ea68c6 100644 --- a/dotnet/src/webdriver/Firefox/FirefoxDriver.cs +++ b/dotnet/src/webdriver/Firefox/FirefoxDriver.cs @@ -413,6 +413,7 @@ public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion) /// Creates a session to communicate with a browser using a Developer Tools debugging protocol. /// /// The active session to use to communicate with the Developer Tools debugging protocol. + [Obsolete("CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.")] public DevToolsSession GetDevToolsSession(DevToolsOptions options) { if (this.devToolsSession == null) diff --git a/dotnet/src/webdriver/Remote/RemoteWebDriver.cs b/dotnet/src/webdriver/Remote/RemoteWebDriver.cs index 35a32af124d78..8483eb2fbc3ec 100644 --- a/dotnet/src/webdriver/Remote/RemoteWebDriver.cs +++ b/dotnet/src/webdriver/Remote/RemoteWebDriver.cs @@ -17,6 +17,7 @@ // under the License. // +using OpenQA.Selenium.Internal.Logging; using OpenQA.Selenium.DevTools; using System; using System.Collections.Generic; @@ -63,6 +64,8 @@ namespace OpenQA.Selenium.Remote /// public class RemoteWebDriver : WebDriver, IDevTools, IHasDownloads { + private static readonly ILogger _logger = OpenQA.Selenium.Internal.Logging.Log.GetLogger(typeof(RemoteWebDriver)); + /// /// The name of the Selenium grid remote DevTools end point capability. /// @@ -425,6 +428,14 @@ public ReadOnlyCollection FindElementsByCssSelector(string cssSelec /// The active session to use to communicate with the Developer Tools debugging protocol. public DevToolsSession GetDevToolsSession() { + if (this.Capabilities.GetCapability(CapabilityType.BrowserName) == "firefox") + { + if (_logger.IsEnabled(LogEventLevel.Warn)) + { + _logger.Warn("CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi."); + } + } + return GetDevToolsSession(new DevToolsOptions() { ProtocolVersion = DevToolsSession.AutoDetectDevToolsProtocolVersion }); }