diff --git a/dotnet/test/common/CustomDriverConfigs/StableChannelChromeDriver.cs b/dotnet/test/common/CustomDriverConfigs/StableChannelChromeDriver.cs index fab38a20b0e50..4bd01ffcea2ff 100644 --- a/dotnet/test/common/CustomDriverConfigs/StableChannelChromeDriver.cs +++ b/dotnet/test/common/CustomDriverConfigs/StableChannelChromeDriver.cs @@ -20,7 +20,7 @@ public StableChannelChromeDriver(ChromeDriverService service, ChromeOptions opti public static ChromeOptions DefaultOptions { - get { return new ChromeOptions() { AcceptInsecureCertificates = true, BrowserVersion = "116" }; } + get { return new ChromeOptions() { BrowserVersion = "116" }; } } } } diff --git a/dotnet/test/common/CustomDriverConfigs/StableChannelEdgeDriver.cs b/dotnet/test/common/CustomDriverConfigs/StableChannelEdgeDriver.cs index 3e43972e964ad..d29ed8f40e680 100644 --- a/dotnet/test/common/CustomDriverConfigs/StableChannelEdgeDriver.cs +++ b/dotnet/test/common/CustomDriverConfigs/StableChannelEdgeDriver.cs @@ -20,7 +20,7 @@ public StableChannelEdgeDriver(EdgeDriverService service, EdgeOptions options) } public static EdgeOptions DefaultOptions { - get { return new EdgeOptions() { AcceptInsecureCertificates = true }; } + get { return new EdgeOptions(); } } } } diff --git a/dotnet/test/common/Environment/DriverConfig.cs b/dotnet/test/common/Environment/DriverConfig.cs index 0dc625cbe8add..17932b9c950d5 100644 --- a/dotnet/test/common/Environment/DriverConfig.cs +++ b/dotnet/test/common/Environment/DriverConfig.cs @@ -26,5 +26,8 @@ public class DriverConfig [JsonProperty] public bool AutoStartRemoteServer { get; set; } + + [JsonProperty] + public bool Logging { get; set; } } } diff --git a/dotnet/test/common/Environment/DriverFactory.cs b/dotnet/test/common/Environment/DriverFactory.cs index c1187629adfc5..3bc8948dab56a 100644 --- a/dotnet/test/common/Environment/DriverFactory.cs +++ b/dotnet/test/common/Environment/DriverFactory.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using OpenQA.Selenium.Chromium; namespace OpenQA.Selenium.Environment { @@ -40,16 +41,17 @@ private void PopulateServiceTypes() public event EventHandler DriverStarting; - public IWebDriver CreateDriver(Type driverType) + public IWebDriver CreateDriver(Type driverType, bool logging = false) { - return CreateDriverWithOptions(driverType, null); + return CreateDriverWithOptions(driverType, null, logging); } - public IWebDriver CreateDriverWithOptions(Type driverType, DriverOptions driverOptions) + public IWebDriver CreateDriverWithOptions(Type driverType, DriverOptions driverOptions, bool logging = false) { Browser browser = Browser.All; DriverService service = null; DriverOptions options = null; + bool enableLogging = logging; List constructorArgTypeList = new List(); IWebDriver driver = null; @@ -58,24 +60,40 @@ public IWebDriver CreateDriverWithOptions(Type driverType, DriverOptions driverO browser = Browser.Chrome; options = GetDriverOptions(driverType, driverOptions); service = CreateService(); + if (enableLogging) + { + ((ChromiumDriverService)service).EnableVerboseLogging = true; + } } else if (typeof(EdgeDriver).IsAssignableFrom(driverType)) { browser = Browser.Edge; options = GetDriverOptions(driverType, driverOptions); service = CreateService(); + if (enableLogging) + { + ((ChromiumDriverService)service).EnableVerboseLogging = true; + } } else if (typeof(InternetExplorerDriver).IsAssignableFrom(driverType)) { browser = Browser.IE; options = GetDriverOptions(driverType, driverOptions); service = CreateService(); + if (enableLogging) + { + ((InternetExplorerDriverService)service).LoggingLevel = InternetExplorerDriverLogLevel.Trace; + } } else if (typeof(FirefoxDriver).IsAssignableFrom(driverType)) { browser = Browser.Firefox; options = GetDriverOptions(driverType, driverOptions); service = CreateService(); + if (enableLogging) + { + ((FirefoxDriverService)service).LogLevel = FirefoxDriverLogLevel.Trace; + } } else if (typeof(SafariDriver).IsAssignableFrom(driverType)) { diff --git a/dotnet/test/common/Environment/EnvironmentManager.cs b/dotnet/test/common/Environment/EnvironmentManager.cs index 1b192c5060bc7..6b79c34e3f90b 100644 --- a/dotnet/test/common/Environment/EnvironmentManager.cs +++ b/dotnet/test/common/Environment/EnvironmentManager.cs @@ -17,6 +17,7 @@ public class EnvironmentManager private DriverFactory driverFactory; private RemoteSeleniumServer remoteServer; private string remoteCapabilities; + private bool logging; private EnvironmentManager() { @@ -52,6 +53,7 @@ private EnvironmentManager() driverType = driverAssembly.GetType(driverConfig.DriverTypeName); browser = driverConfig.BrowserValue; remoteCapabilities = driverConfig.RemoteCapabilities; + logging = driverConfig.Logging; urlBuilder = new UrlBuilder(websiteConfig); @@ -190,6 +192,11 @@ public string RemoteCapabilities get { return remoteCapabilities; } } + public bool Logging + { + get { return logging; } + } + public UrlBuilder UrlBuilder { get @@ -210,12 +217,12 @@ public IWebDriver GetCurrentDriver() public IWebDriver CreateDriverInstance() { - return driverFactory.CreateDriver(driverType); + return driverFactory.CreateDriver(driverType, Logging); } public IWebDriver CreateDriverInstance(DriverOptions options) { - return driverFactory.CreateDriverWithOptions(driverType, options); + return driverFactory.CreateDriverWithOptions(driverType, options, Logging); } public IWebDriver CreateFreshDriver() diff --git a/dotnet/test/common/appconfig.json b/dotnet/test/common/appconfig.json index 41f2c3d64a5a8..3bb05d483db4e 100644 --- a/dotnet/test/common/appconfig.json +++ b/dotnet/test/common/appconfig.json @@ -27,63 +27,72 @@ "DriverTypeName": "OpenQA.Selenium.Chrome.StableChannelChromeDriver", "AssemblyName": "WebDriver.Common.Tests", "BrowserValue": "Chrome", - "RemoteCapabilities": "chrome" + "RemoteCapabilities": "chrome", + "Logging": false }, "ChromeDev": { "DriverTypeName": "OpenQA.Selenium.Chrome.DevChannelChromeDriver", "AssemblyName": "WebDriver.Common.Tests", "BrowserValue": "Chrome", - "RemoteCapabilities": "chrome" + "RemoteCapabilities": "chrome", + "Logging": false }, "EdgeIEMode": { "DriverTypeName": "OpenQA.Selenium.IE.EdgeInternetExplorerModeDriver", "AssemblyName": "WebDriver.Common.Tests", "BrowserValue": "IE", - "RemoteCapabilities": "internet explorer" + "RemoteCapabilities": "internet explorer", + "Logging": false }, "Edge": { "DriverTypeName": "OpenQA.Selenium.Edge.StableChannelEdgeDriver", "AssemblyName": "WebDriver.Common.Tests", "BrowserValue": "Edge", - "RemoteCapabilities": "MicrosoftEdge" + "RemoteCapabilities": "MicrosoftEdge", + "Logging": false }, "EdgeDev": { "DriverTypeName": "OpenQA.Selenium.Edge.DevChannelEdgeDriver", "AssemblyName": "WebDriver.Common.Tests", "BrowserValue": "Edge", - "RemoteCapabilities": "MicrosoftEdge" + "RemoteCapabilities": "MicrosoftEdge", + "Logging": false }, "Firefox": { "DriverTypeName": "OpenQA.Selenium.Firefox.StableChannelFirefoxDriver", "AssemblyName": "WebDriver.Common.Tests", "BrowserValue": "Firefox", - "RemoteCapabilities": "firefox" + "RemoteCapabilities": "firefox", + "Logging": false }, "FirefoxNightly": { "DriverTypeName": "OpenQA.Selenium.Firefox.NightlyChannelFirefoxDriver", "AssemblyName": "WebDriver.Common.Tests", "BrowserValue": "Firefox", - "RemoteCapabilities": "firefox" + "RemoteCapabilities": "firefox", + "Logging": false }, "Safari": { "DriverTypeName": "OpenQA.Selenium.Safari.DefaultSafariDriver", "AssemblyName": "WebDriver.Common.Tests", "BrowserValue": "Safari", - "RemoteCapabilities": "safari" + "RemoteCapabilities": "safari", + "Logging": false }, "SafariTechPreview": { "DriverTypeName": "OpenQA.Selenium.Safari.SafariTechnologyPreviewDriver", "AssemblyName": "WebDriver.Common.Tests", "BrowserValue": "Safari", - "RemoteCapabilities": "safari" + "RemoteCapabilities": "safari", + "Logging": false }, "Remote": { @@ -91,7 +100,8 @@ "AssemblyName": "WebDriver.Common.Tests", "BrowserValue": "Remote", "RemoteCapabilities": "chrome", - "AutoStartRemoteServer": true + "AutoStartRemoteServer": true, + "Logging": false } } }