diff --git a/dotnet/test/common/AlertsTest.cs b/dotnet/test/common/AlertsTest.cs index 7bf5985d01a37..f2255c1964a66 100644 --- a/dotnet/test/common/AlertsTest.cs +++ b/dotnet/test/common/AlertsTest.cs @@ -420,7 +420,7 @@ public void ShouldNotHandleAlertInAnotherWindow() IWebElement el = driver.FindElement(By.Id("open-new-window")); WaitFor(AlertToBePresent, TimeSpan.FromSeconds(5), "No alert found"); }, - Throws.TypeOf()); + Throws.InstanceOf()); } finally diff --git a/dotnet/test/common/BiDi/Browser/BrowserTest.cs b/dotnet/test/common/BiDi/Browser/BrowserTest.cs index 44f4309850fce..2c1e9f781eca3 100644 --- a/dotnet/test/common/BiDi/Browser/BrowserTest.cs +++ b/dotnet/test/common/BiDi/Browser/BrowserTest.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Browser; -class BrowserTest : BiDiTestFixture +internal class BrowserTest : BiDiTestFixture { [Test] public async Task CanCreateUserContext() diff --git a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextEventsTest.cs b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextEventsTest.cs index 503fcaee56431..56b4fc8176d6e 100644 --- a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextEventsTest.cs +++ b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextEventsTest.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -class BrowsingContextEventsTest : BiDiTestFixture +internal class BrowsingContextEventsTest : BiDiTestFixture { [Test] [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] diff --git a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs index 9a62004bede8b..277ac42ffd7c4 100644 --- a/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs +++ b/dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -class BrowsingContextTest : BiDiTestFixture +internal class BrowsingContextTest : BiDiTestFixture { [Test] public async Task CanCreateNewTab() diff --git a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs index 0f5c79295a452..114580e2d11ad 100644 --- a/dotnet/test/common/BiDi/Emulation/EmulationTest.cs +++ b/dotnet/test/common/BiDi/Emulation/EmulationTest.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Emulation; -class EmulationTest : BiDiTestFixture +internal class EmulationTest : BiDiTestFixture { [Test] [IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")] diff --git a/dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs b/dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs index 84367fc1d7983..4c18f1d9f6b1f 100644 --- a/dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs +++ b/dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Input; -class CombinedInputActionsTest : BiDiTestFixture +internal class CombinedInputActionsTest : BiDiTestFixture { //[Test] public async Task Paint() diff --git a/dotnet/test/common/BiDi/Input/SetFilesTest.cs b/dotnet/test/common/BiDi/Input/SetFilesTest.cs index 1f58ecbd408a4..0f5a54b96dbda 100644 --- a/dotnet/test/common/BiDi/Input/SetFilesTest.cs +++ b/dotnet/test/common/BiDi/Input/SetFilesTest.cs @@ -24,9 +24,9 @@ namespace OpenQA.Selenium.BiDi.Input; -class SetFilesTest : BiDiTestFixture +internal class SetFilesTest : BiDiTestFixture { - string _tempFile; + private string _tempFile; [SetUp] public void SetUp() diff --git a/dotnet/test/common/BiDi/Log/LogTest.cs b/dotnet/test/common/BiDi/Log/LogTest.cs index d9ec07c268b2c..0e296704c7793 100644 --- a/dotnet/test/common/BiDi/Log/LogTest.cs +++ b/dotnet/test/common/BiDi/Log/LogTest.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Log; -class LogTest : BiDiTestFixture +internal class LogTest : BiDiTestFixture { [Test] public async Task CanListenToConsoleLog() diff --git a/dotnet/test/common/BiDi/Network/NetworkEventsTest.cs b/dotnet/test/common/BiDi/Network/NetworkEventsTest.cs index 5a8cb5ce609ce..7f223578e963c 100644 --- a/dotnet/test/common/BiDi/Network/NetworkEventsTest.cs +++ b/dotnet/test/common/BiDi/Network/NetworkEventsTest.cs @@ -24,7 +24,7 @@ namespace OpenQA.Selenium.BiDi.Network; -class NetworkEventsTest : BiDiTestFixture +internal class NetworkEventsTest : BiDiTestFixture { [Test] public async Task CanListenToBeforeRequestSentEvent() diff --git a/dotnet/test/common/BiDi/Network/NetworkTest.cs b/dotnet/test/common/BiDi/Network/NetworkTest.cs index 25c46a33b8eca..d9dc70209d971 100644 --- a/dotnet/test/common/BiDi/Network/NetworkTest.cs +++ b/dotnet/test/common/BiDi/Network/NetworkTest.cs @@ -24,7 +24,7 @@ namespace OpenQA.Selenium.BiDi.Network; -class NetworkTest : BiDiTestFixture +internal class NetworkTest : BiDiTestFixture { [Test] public async Task CanAddDataCollector() diff --git a/dotnet/test/common/BiDi/Script/CallFunctionLocalValueTest.cs b/dotnet/test/common/BiDi/Script/CallFunctionLocalValueTest.cs index 6a75d595c5034..4ec70c96060a9 100644 --- a/dotnet/test/common/BiDi/Script/CallFunctionLocalValueTest.cs +++ b/dotnet/test/common/BiDi/Script/CallFunctionLocalValueTest.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Script; -class CallFunctionLocalValueTest : BiDiTestFixture +internal class CallFunctionLocalValueTest : BiDiTestFixture { [Test] public async Task CanCallFunctionWithArgumentUndefined() diff --git a/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs b/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs index 666643f335f14..85f4f452dc2e4 100644 --- a/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs +++ b/dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Script; -class CallFunctionParameterTest : BiDiTestFixture +internal class CallFunctionParameterTest : BiDiTestFixture { [Test] public async Task CanCallFunctionWithDeclaration() diff --git a/dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs b/dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs index 060f4a0e1a77a..5dcfb4e2e54b3 100644 --- a/dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs +++ b/dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Script; -class EvaluateParametersTest : BiDiTestFixture +internal class EvaluateParametersTest : BiDiTestFixture { [Test] public async Task CanEvaluateScript() diff --git a/dotnet/test/common/BiDi/Script/LocalValueConversionTests.cs b/dotnet/test/common/BiDi/Script/LocalValueConversionTests.cs index 7a19a3c239129..492ff44684eba 100644 --- a/dotnet/test/common/BiDi/Script/LocalValueConversionTests.cs +++ b/dotnet/test/common/BiDi/Script/LocalValueConversionTests.cs @@ -25,7 +25,7 @@ namespace OpenQA.Selenium.BiDi.Script; -class LocalValueConversionTests +internal class LocalValueConversionTests { [Test] public void CanConvertNullBoolToLocalValue() diff --git a/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs b/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs index f12882bf7128b..3f4b86d753935 100644 --- a/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs +++ b/dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Script; -class ScriptCommandsTest : BiDiTestFixture +internal class ScriptCommandsTest : BiDiTestFixture { [Test] public async Task CanGetAllRealms() diff --git a/dotnet/test/common/BiDi/Script/ScriptEventsTest.cs b/dotnet/test/common/BiDi/Script/ScriptEventsTest.cs index 182255a27facf..711e1e4450260 100644 --- a/dotnet/test/common/BiDi/Script/ScriptEventsTest.cs +++ b/dotnet/test/common/BiDi/Script/ScriptEventsTest.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.BiDi.Script; -class ScriptEventsTest : BiDiTestFixture +internal class ScriptEventsTest : BiDiTestFixture { [Test] public async Task CanListenToChannelMessage() diff --git a/dotnet/test/common/BiDi/Storage/StorageTest.cs b/dotnet/test/common/BiDi/Storage/StorageTest.cs index 4fa13039787af..358972d7357da 100644 --- a/dotnet/test/common/BiDi/Storage/StorageTest.cs +++ b/dotnet/test/common/BiDi/Storage/StorageTest.cs @@ -24,7 +24,7 @@ namespace OpenQA.Selenium.BiDi.Storage; -class StorageTest : BiDiTestFixture +internal class StorageTest : BiDiTestFixture { [Test] public async Task CanGetCookieByName() diff --git a/dotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs b/dotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs index 19f1c8464ecbe..21569d40ea034 100644 --- a/dotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs +++ b/dotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs @@ -25,9 +25,9 @@ namespace OpenQA.Selenium.BiDi.WebExtension; [IgnoreBrowser(Selenium.Browser.Chrome, ChromiumIgnoreReason)] [IgnoreBrowser(Selenium.Browser.Edge, ChromiumIgnoreReason)] -class WebExtensionTest : BiDiTestFixture +internal class WebExtensionTest : BiDiTestFixture { - const string ChromiumIgnoreReason = """ + private const string ChromiumIgnoreReason = """ The following test suite wants to set driver arguments via Options, but it breaks CDP/DevTools tests. The desired arguments (for Chromium only?): --enable-unsafe-extension-debugging diff --git a/dotnet/test/common/CookieImplementationTest.cs b/dotnet/test/common/CookieImplementationTest.cs index edec97e6200ea..f9fbfeb27100c 100644 --- a/dotnet/test/common/CookieImplementationTest.cs +++ b/dotnet/test/common/CookieImplementationTest.cs @@ -30,7 +30,7 @@ namespace OpenQA.Selenium; [TestFixture] public class CookieImplementationTest : DriverTestFixture { - private Random random = new Random(); + private readonly Random random = new Random(); private bool isOnAlternativeHostName; private string hostname; @@ -50,7 +50,7 @@ public void ShouldGetCookieByName() return; } - string key = string.Format("key_{0}", new Random().Next()); + string key = string.Format("key_{0}", random.Next()); ((IJavaScriptExecutor)driver).ExecuteScript("document.cookie = arguments[0] + '=set';", key); Cookie cookie = driver.Manage().Cookies.GetCookieNamed(key); @@ -932,8 +932,7 @@ private string GenerateUniqueKey() private string GetDocumentCookieOrNull() { - IJavaScriptExecutor jsDriver = driver as IJavaScriptExecutor; - if (jsDriver == null) + if (driver is not IJavaScriptExecutor jsDriver) { return null; } diff --git a/dotnet/test/common/CorrectEventFiringTest.cs b/dotnet/test/common/CorrectEventFiringTest.cs index e540df5dbae7b..0494316c54852 100644 --- a/dotnet/test/common/CorrectEventFiringTest.cs +++ b/dotnet/test/common/CorrectEventFiringTest.cs @@ -256,7 +256,7 @@ public void ShouldFireTwoClickEventsWhenClickingOnALabel() driver.FindElement(By.Id("labelForCheckbox")).Click(); IWebElement result = driver.FindElement(By.Id("result")); - Assert.That(WaitFor(() => { return result.Text.Contains("labelclick chboxclick"); }, "Did not find text: " + result.Text), Is.True); + Assert.That(() => WaitFor(() => { return result.Text.Contains("labelclick chboxclick"); }, "Did not find text: " + result.Text), Throws.Nothing); } diff --git a/dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs b/dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs index 2c25a9af0e7b1..2e1a74b25377a 100644 --- a/dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs +++ b/dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs @@ -37,8 +37,5 @@ public DevChannelChromeDriver(ChromeDriverService service, ChromeOptions options { } - public static ChromeOptions DefaultOptions - { - get { return new ChromeOptions() { BrowserVersion = "dev" }; } - } + public static ChromeOptions DefaultOptions => new ChromeOptions() { BrowserVersion = "dev" }; } diff --git a/dotnet/test/common/CustomDriverConfigs/DevChannelEdgeDriver.cs b/dotnet/test/common/CustomDriverConfigs/DevChannelEdgeDriver.cs index f29fffae47267..9827f40c4a6dc 100644 --- a/dotnet/test/common/CustomDriverConfigs/DevChannelEdgeDriver.cs +++ b/dotnet/test/common/CustomDriverConfigs/DevChannelEdgeDriver.cs @@ -37,8 +37,5 @@ public DevChannelEdgeDriver(EdgeDriverService service, EdgeOptions options) { } - public static EdgeOptions DefaultOptions - { - get { return new EdgeOptions() { BrowserVersion = "dev" }; } - } + public static EdgeOptions DefaultOptions => new EdgeOptions() { BrowserVersion = "dev" }; } diff --git a/dotnet/test/common/CustomDriverConfigs/EdgeInternetExplorerModeDriver.cs b/dotnet/test/common/CustomDriverConfigs/EdgeInternetExplorerModeDriver.cs index a5f5c7788d97f..da9163f102558 100644 --- a/dotnet/test/common/CustomDriverConfigs/EdgeInternetExplorerModeDriver.cs +++ b/dotnet/test/common/CustomDriverConfigs/EdgeInternetExplorerModeDriver.cs @@ -40,8 +40,5 @@ public EdgeInternetExplorerModeDriver(InternetExplorerDriverService service, Int { } - public static InternetExplorerOptions DefaultOptions - { - get { return new InternetExplorerOptions() { RequireWindowFocus = true, UsePerProcessProxy = true, AttachToEdgeChrome = true }; } - } + public static InternetExplorerOptions DefaultOptions => new InternetExplorerOptions() { RequireWindowFocus = true, UsePerProcessProxy = true, AttachToEdgeChrome = true }; } diff --git a/dotnet/test/common/CustomDriverConfigs/NightlyChannelFirefoxDriver.cs b/dotnet/test/common/CustomDriverConfigs/NightlyChannelFirefoxDriver.cs index 0d54b31414e23..87a662f20b74b 100644 --- a/dotnet/test/common/CustomDriverConfigs/NightlyChannelFirefoxDriver.cs +++ b/dotnet/test/common/CustomDriverConfigs/NightlyChannelFirefoxDriver.cs @@ -40,8 +40,5 @@ public NightlyChannelFirefoxDriver(FirefoxDriverService service, FirefoxOptions { } - public static FirefoxOptions DefaultOptions - { - get { return new FirefoxOptions() { BrowserVersion = "nightly", AcceptInsecureCertificates = true, EnableDevToolsProtocol = true }; } - } + public static FirefoxOptions DefaultOptions => new FirefoxOptions() { BrowserVersion = "nightly", AcceptInsecureCertificates = true, EnableDevToolsProtocol = true }; } diff --git a/dotnet/test/common/CustomDriverConfigs/StableChannelChromeDriver.cs b/dotnet/test/common/CustomDriverConfigs/StableChannelChromeDriver.cs index 77981244fc789..7b11dbf91e500 100644 --- a/dotnet/test/common/CustomDriverConfigs/StableChannelChromeDriver.cs +++ b/dotnet/test/common/CustomDriverConfigs/StableChannelChromeDriver.cs @@ -37,8 +37,5 @@ public StableChannelChromeDriver(ChromeDriverService service, ChromeOptions opti { } - public static ChromeOptions DefaultOptions - { - get { return new ChromeOptions(); } - } + public static ChromeOptions DefaultOptions => new ChromeOptions(); } diff --git a/dotnet/test/common/CustomDriverConfigs/StableChannelEdgeDriver.cs b/dotnet/test/common/CustomDriverConfigs/StableChannelEdgeDriver.cs index 64f8e58f59668..13f110984b463 100644 --- a/dotnet/test/common/CustomDriverConfigs/StableChannelEdgeDriver.cs +++ b/dotnet/test/common/CustomDriverConfigs/StableChannelEdgeDriver.cs @@ -37,8 +37,5 @@ public StableChannelEdgeDriver(EdgeDriverService service, EdgeOptions options) : base(service, options) { } - public static EdgeOptions DefaultOptions - { - get { return new EdgeOptions(); } - } + public static EdgeOptions DefaultOptions => new EdgeOptions(); } diff --git a/dotnet/test/common/CustomDriverConfigs/StableChannelFirefoxDriver.cs b/dotnet/test/common/CustomDriverConfigs/StableChannelFirefoxDriver.cs index 800e8d9cd172c..39e46b3824a7c 100644 --- a/dotnet/test/common/CustomDriverConfigs/StableChannelFirefoxDriver.cs +++ b/dotnet/test/common/CustomDriverConfigs/StableChannelFirefoxDriver.cs @@ -40,8 +40,5 @@ public StableChannelFirefoxDriver(FirefoxDriverService service, FirefoxOptions o { } - public static FirefoxOptions DefaultOptions - { - get { return new FirefoxOptions() { AcceptInsecureCertificates = true, EnableDevToolsProtocol = true }; } - } + public static FirefoxOptions DefaultOptions => new FirefoxOptions() { AcceptInsecureCertificates = true, EnableDevToolsProtocol = true }; } diff --git a/dotnet/test/common/CustomTestAttributes/IgnoreBrowserAttribute.cs b/dotnet/test/common/CustomTestAttributes/IgnoreBrowserAttribute.cs index 9d5b1e6485e41..a9532242c8cd2 100644 --- a/dotnet/test/common/CustomTestAttributes/IgnoreBrowserAttribute.cs +++ b/dotnet/test/common/CustomTestAttributes/IgnoreBrowserAttribute.cs @@ -27,57 +27,34 @@ namespace OpenQA.Selenium; [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] -public class IgnoreBrowserAttribute : NUnitAttribute, IApplyToTest +public class IgnoreBrowserAttribute(Browser browser) : NUnitAttribute, IApplyToTest { - private readonly Browser browser; - private readonly string ignoreReason = string.Empty; - - public IgnoreBrowserAttribute(Browser browser) - { - this.browser = browser; - } - public IgnoreBrowserAttribute(Browser browser, string reason) : this(browser) { - this.ignoreReason = reason; + Reason = reason; } - public Browser Value - { - get { return browser; } - } + public Browser Value { get; } = browser; - public string Reason - { - get { return ignoreReason; } - } + public string Reason { get; } = string.Empty; public void ApplyToTest(Test test) { if (test.RunState != RunState.NotRunnable) { - List ignoreAttributes = new List(); + IgnoreBrowserAttribute[] ignoreAttributes; if (test.IsSuite) { - Attribute[] ignoreClassAttributes = test.TypeInfo.GetCustomAttributes(true); - if (ignoreClassAttributes.Length > 0) - { - ignoreAttributes.AddRange(ignoreClassAttributes); - } + ignoreAttributes = test.TypeInfo.GetCustomAttributes(true); } else { - IgnoreBrowserAttribute[] ignoreMethodAttributes = test.Method.GetCustomAttributes(true); - if (ignoreMethodAttributes.Length > 0) - { - ignoreAttributes.AddRange(ignoreMethodAttributes); - } + ignoreAttributes = test.Method.GetCustomAttributes(true); } - foreach (Attribute attr in ignoreAttributes) + foreach (IgnoreBrowserAttribute browserToIgnoreAttr in ignoreAttributes) { - IgnoreBrowserAttribute browserToIgnoreAttr = attr as IgnoreBrowserAttribute; if (browserToIgnoreAttr != null && IgnoreTestForBrowser(browserToIgnoreAttr.Value)) { string ignoreReason = "Ignoring browser " + EnvironmentManager.Instance.Browser.ToString() + "."; @@ -87,7 +64,7 @@ public void ApplyToTest(Test test) } test.RunState = RunState.Ignored; - test.Properties.Set(PropertyNames.SkipReason, browserToIgnoreAttr.Reason); + test.Properties.Set(PropertyNames.SkipReason, ignoreReason); } } } diff --git a/dotnet/test/common/CustomTestAttributes/IgnorePlatformAttribute.cs b/dotnet/test/common/CustomTestAttributes/IgnorePlatformAttribute.cs index 73de23fc43c36..4a0e2092fb647 100644 --- a/dotnet/test/common/CustomTestAttributes/IgnorePlatformAttribute.cs +++ b/dotnet/test/common/CustomTestAttributes/IgnorePlatformAttribute.cs @@ -30,70 +30,44 @@ namespace OpenQA.Selenium; [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] -public class IgnorePlatformAttribute : NUnitAttribute, IApplyToTest +public class IgnorePlatformAttribute(string platform) : NUnitAttribute, IApplyToTest { - private readonly String platform; - private readonly string ignoreReason = string.Empty; - - public IgnorePlatformAttribute(string platform) - { - this.platform = platform.ToLower(); - } - public IgnorePlatformAttribute(string platform, string reason) : this(platform) { - this.ignoreReason = reason; + Reason = reason; } - public string Value - { - get { return platform; } - } + public string Value { get; } = platform; - public string Reason - { - get { return ignoreReason; } - } + public string Reason { get; } = string.Empty; public void ApplyToTest(Test test) { if (test.RunState != RunState.NotRunnable) { - List ignoreAttributes = new List(); + IgnorePlatformAttribute[] ignoreAttributes; if (test.IsSuite) { - Attribute[] ignoreClassAttributes = - test.TypeInfo.GetCustomAttributes(true); - if (ignoreClassAttributes.Length > 0) - { - ignoreAttributes.AddRange(ignoreClassAttributes); - } + ignoreAttributes = test.TypeInfo.GetCustomAttributes(true); } else { - IgnorePlatformAttribute[] ignoreMethodAttributes = - test.Method.GetCustomAttributes(true); - if (ignoreMethodAttributes.Length > 0) - { - ignoreAttributes.AddRange(ignoreMethodAttributes); - } + ignoreAttributes = test.Method.GetCustomAttributes(true); } - foreach (Attribute attr in ignoreAttributes) + foreach (IgnorePlatformAttribute platformToIgnoreAttr in ignoreAttributes) { - IgnorePlatformAttribute platformToIgnoreAttr = attr as IgnorePlatformAttribute; - if (platformToIgnoreAttr != null && IgnoreTestForPlatform(platformToIgnoreAttr.Value)) + if (IgnoreTestForPlatform(platformToIgnoreAttr.Value)) { - string ignoreReason = - "Ignoring platform " + EnvironmentManager.Instance.Browser.ToString() + "."; + string ignoreReason = "Ignoring platform " + EnvironmentManager.Instance.Browser.ToString() + "."; if (!string.IsNullOrEmpty(platformToIgnoreAttr.Reason)) { ignoreReason = ignoreReason + " " + platformToIgnoreAttr.Reason; } test.RunState = RunState.Ignored; - test.Properties.Set(PropertyNames.SkipReason, platformToIgnoreAttr.Reason); + test.Properties.Set(PropertyNames.SkipReason, ignoreReason); } } } @@ -101,7 +75,7 @@ public void ApplyToTest(Test test) private bool IgnoreTestForPlatform(string platformToIgnore) { - return CurrentPlatform() != null && platformToIgnore.Equals(CurrentPlatform()); + return platformToIgnore.Equals(CurrentPlatform(), StringComparison.OrdinalIgnoreCase); } private string CurrentPlatform() diff --git a/dotnet/test/common/CustomTestAttributes/IgnoreTargetAttribute.cs b/dotnet/test/common/CustomTestAttributes/IgnoreTargetAttribute.cs index 8b75e6913a04a..b9815e03e9284 100644 --- a/dotnet/test/common/CustomTestAttributes/IgnoreTargetAttribute.cs +++ b/dotnet/test/common/CustomTestAttributes/IgnoreTargetAttribute.cs @@ -28,20 +28,15 @@ namespace OpenQA.Selenium; [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] -public class IgnoreTargetAttribute : NUnitAttribute, IApplyToTest +public class IgnoreTargetAttribute(string target) : NUnitAttribute, IApplyToTest { - public IgnoreTargetAttribute(string target) - { - this.Value = target.ToLower(); - } - public IgnoreTargetAttribute(string target, string reason) : this(target) { this.Reason = reason; } - public string Value { get; } + public string Value { get; } = target.ToLower(); public string Reason { get; } = string.Empty; diff --git a/dotnet/test/common/DevTools/DevToolsSecurityTest.cs b/dotnet/test/common/DevTools/DevToolsSecurityTest.cs index 8a94c0e783d89..5874298a0f120 100644 --- a/dotnet/test/common/DevTools/DevToolsSecurityTest.cs +++ b/dotnet/test/common/DevTools/DevToolsSecurityTest.cs @@ -30,7 +30,7 @@ namespace OpenQA.Selenium.DevTools; [TestFixture] public class DevToolsSecurityTest : DevToolsTestFixture { - //[Test] + [Test, Ignore("")] [IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")] [IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")] [IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")] diff --git a/dotnet/test/common/DevTools/DevToolsTargetTest.cs b/dotnet/test/common/DevTools/DevToolsTargetTest.cs index f710c775cbe98..e7011cb17671d 100644 --- a/dotnet/test/common/DevTools/DevToolsTargetTest.cs +++ b/dotnet/test/common/DevTools/DevToolsTargetTest.cs @@ -30,7 +30,7 @@ namespace OpenQA.Selenium.DevTools; [TestFixture] public class DevToolsTargetTest : DevToolsTestFixture { - private int id = 143; + private const int id = 143; [Test] [IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")] diff --git a/dotnet/test/common/DevTools/DevToolsTestFixture.cs b/dotnet/test/common/DevTools/DevToolsTestFixture.cs index c5c1d7709f174..36618d45e922b 100644 --- a/dotnet/test/common/DevTools/DevToolsTestFixture.cs +++ b/dotnet/test/common/DevTools/DevToolsTestFixture.cs @@ -19,6 +19,7 @@ using NUnit.Framework; using OpenQA.Selenium.Environment; +using System.Diagnostics.CodeAnalysis; namespace OpenQA.Selenium.DevTools; @@ -27,10 +28,8 @@ public class DevToolsTestFixture : DriverTestFixture protected IDevTools devTools; protected IDevToolsSession session; - public bool IsDevToolsSupported - { - get { return devTools != null; } - } + [MemberNotNullWhen(true, nameof(devTools))] + public bool IsDevToolsSupported => devTools != null; [SetUp] public void Setup() diff --git a/dotnet/test/common/DriverTestFixture.cs b/dotnet/test/common/DriverTestFixture.cs index 68bb9917d954b..de0dc266ffa74 100644 --- a/dotnet/test/common/DriverTestFixture.cs +++ b/dotnet/test/common/DriverTestFixture.cs @@ -19,6 +19,7 @@ using NUnit.Framework; using OpenQA.Selenium.Environment; +using OpenQA.Selenium.Support.UI; using System; using static NUnit.Framework.Interfaces.ResultState; @@ -141,61 +142,37 @@ public void ResetOnError() } } - /* - * Exists because a given test might require a fresh driver - */ + /// + /// Exists because a given test might require a fresh driver. + /// protected void CreateFreshDriver() { driver = EnvironmentManager.Instance.CreateFreshDriver(); } - protected bool WaitFor(Func waitFunction, string timeoutMessage) + protected void WaitFor(Func waitFunction, string timeoutMessage) { - return WaitFor(waitFunction, timeoutMessage); + WaitFor(waitFunction, timeoutMessage); } protected T WaitFor(Func waitFunction, string timeoutMessage) { - return this.WaitFor(waitFunction, TimeSpan.FromSeconds(5), timeoutMessage); + return WaitFor(waitFunction, TimeSpan.FromSeconds(5), timeoutMessage); } protected T WaitFor(Func waitFunction, TimeSpan timeout, string timeoutMessage) { - DateTime endTime = DateTime.Now.Add(timeout); - T value = default; - Exception lastException = null; - while (DateTime.Now < endTime) + var waiter = new WebDriverWait(driver, timeout) { - try - { - value = waitFunction(); - if (typeof(T) == typeof(bool)) - { - if ((bool)(object)value) - { - return value; - } - } - else if (value != null) - { - return value; - } - - System.Threading.Thread.Sleep(100); - } - catch (Exception e) - { - // Swallow for later re-throwing - lastException = e; - } - } + PollingInterval = TimeSpan.FromMilliseconds(100), + Message = $"Condition timed out: {timeoutMessage}", + }; - if (lastException != null) - { - throw new WebDriverException("Operation timed out", lastException); - } + waiter.IgnoreExceptionTypes(typeof(Exception)); - Assert.Fail("Condition timed out: " + timeoutMessage); - return default; + return waiter.Until((driver) => + { + return waitFunction(); + }); } } diff --git a/dotnet/test/common/ElementSelectingTest.cs b/dotnet/test/common/ElementSelectingTest.cs index 5a663902deee9..2f70133403214 100644 --- a/dotnet/test/common/ElementSelectingTest.cs +++ b/dotnet/test/common/ElementSelectingTest.cs @@ -269,77 +269,23 @@ private static void AssertTogglingSwapsSelectedStateFrom(IWebElement element, bo //TODO: Test selecting options - private IWebElement EnabledUnselectedCheckbox - { - get - { - return driver.FindElement(By.Id("checky")); - } - } + private IWebElement EnabledUnselectedCheckbox => driver.FindElement(By.Id("checky")); - private IWebElement EnabledSelectedCheckbox - { - get - { - return driver.FindElement(By.Id("checkedchecky")); - } - } + private IWebElement EnabledSelectedCheckbox => driver.FindElement(By.Id("checkedchecky")); - private IWebElement DisabledUnselectedCheckbox - { - get - { - return driver.FindElement(By.Id("disabledchecky")); - } - } + private IWebElement DisabledUnselectedCheckbox => driver.FindElement(By.Id("disabledchecky")); - private IWebElement RandomlyDisabledSelectedCheckbox - { - get - { - return driver.FindElement(By.Id("randomly_disabled_checky")); - } - } + private IWebElement RandomlyDisabledSelectedCheckbox => driver.FindElement(By.Id("randomly_disabled_checky")); - private IWebElement EnabledUnselectedRadioButton - { - get - { - return driver.FindElement(By.Id("peas")); - } - } + private IWebElement EnabledUnselectedRadioButton => driver.FindElement(By.Id("peas")); - private IWebElement EnabledSelectedRadioButton - { - get - { - return driver.FindElement(By.Id("cheese_and_peas")); - } - } + private IWebElement EnabledSelectedRadioButton => driver.FindElement(By.Id("cheese_and_peas")); - private IWebElement DisabledSelectedRadioButton - { - get - { - return driver.FindElement(By.Id("lone_disabled_selected_radio")); - } - } + private IWebElement DisabledSelectedRadioButton => driver.FindElement(By.Id("lone_disabled_selected_radio")); - private IWebElement DisabledUnselectedRadioButton - { - get - { - return driver.FindElement(By.Id("nothing")); - } - } + private IWebElement DisabledUnselectedRadioButton => driver.FindElement(By.Id("nothing")); - private IWebElement RandomlyDisabledUnselectedRadioButton - { - get - { - return driver.FindElement(By.Id("randomly_disabled_nothing")); - } - } + private IWebElement RandomlyDisabledUnselectedRadioButton => driver.FindElement(By.Id("randomly_disabled_nothing")); private IWebElement SelectedMultipleSelectOption { @@ -350,11 +296,5 @@ private IWebElement SelectedMultipleSelectOption } } - private IWebElement NonSelectableElement - { - get - { - return driver.FindElement(By.TagName("div")); - } - } + private IWebElement NonSelectableElement => driver.FindElement(By.TagName("div")); } diff --git a/dotnet/test/common/Environment/DriverFactory.cs b/dotnet/test/common/Environment/DriverFactory.cs index f58eea2430673..41c41fa8f63c0 100644 --- a/dotnet/test/common/Environment/DriverFactory.cs +++ b/dotnet/test/common/Environment/DriverFactory.cs @@ -32,10 +32,10 @@ namespace OpenQA.Selenium.Environment; public class DriverFactory { - string driverPath; - string browserBinaryLocation; - private Dictionary serviceTypes = new Dictionary(); - private Dictionary optionsTypes = new Dictionary(); + private readonly string driverPath; + private readonly string browserBinaryLocation; + private readonly Dictionary serviceTypes = new Dictionary(); + private readonly Dictionary optionsTypes = new Dictionary(); public DriverFactory(string driverPath, string browserBinaryLocation) { diff --git a/dotnet/test/common/Environment/DriverStartingEventArgs.cs b/dotnet/test/common/Environment/DriverStartingEventArgs.cs index 82183b0ad7d7b..7b710feb765d0 100644 --- a/dotnet/test/common/Environment/DriverStartingEventArgs.cs +++ b/dotnet/test/common/Environment/DriverStartingEventArgs.cs @@ -19,18 +19,9 @@ namespace OpenQA.Selenium.Environment; -public class DriverStartingEventArgs +public class DriverStartingEventArgs(DriverService service, DriverOptions options) { - DriverService service; - DriverOptions options; + public DriverService Service { get; } = service; - public DriverStartingEventArgs(DriverService service, DriverOptions options) - { - this.Service = service; - this.Options = options; - } - - public DriverService Service { get => service; set => service = value; } - - public DriverOptions Options { get => options; set => options = value; } + public DriverOptions Options { get; } = options; } diff --git a/dotnet/test/common/Environment/InlinePage.cs b/dotnet/test/common/Environment/InlinePage.cs index bed0ad7d54fd0..3dc6ff0683786 100644 --- a/dotnet/test/common/Environment/InlinePage.cs +++ b/dotnet/test/common/Environment/InlinePage.cs @@ -25,9 +25,9 @@ namespace OpenQA.Selenium.Environment; public class InlinePage { private string title = string.Empty; - private List scripts = new List(); - private List styles = new List(); - private List bodyParts = new List(); + private readonly List scripts = new List(); + private readonly List styles = new List(); + private readonly List bodyParts = new List(); private string onLoad; private string onBeforeUnload; diff --git a/dotnet/test/common/Environment/RemoteSeleniumServer.cs b/dotnet/test/common/Environment/RemoteSeleniumServer.cs index bc9fed6f5b8fe..e9f309ac553d4 100644 --- a/dotnet/test/common/Environment/RemoteSeleniumServer.cs +++ b/dotnet/test/common/Environment/RemoteSeleniumServer.cs @@ -26,25 +26,19 @@ namespace OpenQA.Selenium.Environment; -public class RemoteSeleniumServer +#nullable enable + +public class RemoteSeleniumServer(string projectRoot, bool autoStartServer) { - private Process webserverProcess; + private Process? webserverProcess; private string serverJarName = @"java/src/org/openqa/selenium/grid/selenium_server_deploy.jar"; - private string projectRootPath; - private bool autoStart; - - public RemoteSeleniumServer(string projectRoot, bool autoStartServer) - { - projectRootPath = projectRoot; - autoStart = autoStartServer; - } public async Task StartAsync() { - if (autoStart && (webserverProcess == null || webserverProcess.HasExited)) + if (autoStartServer && (webserverProcess == null || webserverProcess.HasExited)) { serverJarName = serverJarName.Replace('/', Path.DirectorySeparatorChar); - if (!File.Exists(Path.Combine(projectRootPath, serverJarName))) + if (!File.Exists(Path.Combine(projectRoot, serverJarName))) { throw new FileNotFoundException( string.Format( @@ -56,7 +50,7 @@ public async Task StartAsync() webserverProcess = new Process(); webserverProcess.StartInfo.FileName = "java.exe"; webserverProcess.StartInfo.Arguments = " -jar " + serverJarName + " standalone --port 6000 --selenium-manager true --enable-managed-downloads true"; - webserverProcess.StartInfo.WorkingDirectory = projectRootPath; + webserverProcess.StartInfo.WorkingDirectory = projectRoot; webserverProcess.Start(); DateTime timeout = DateTime.Now.Add(TimeSpan.FromSeconds(30)); bool isRunning = false; @@ -89,7 +83,7 @@ public async Task StartAsync() public async Task StopAsync() { - if (autoStart && webserverProcess != null && !webserverProcess.HasExited) + if (autoStartServer && webserverProcess != null && !webserverProcess.HasExited) { using (var httpClient = new HttpClient()) { diff --git a/dotnet/test/common/Environment/TestEnvironment.cs b/dotnet/test/common/Environment/TestEnvironment.cs index 017424d61f703..33d8b3a56f20b 100644 --- a/dotnet/test/common/Environment/TestEnvironment.cs +++ b/dotnet/test/common/Environment/TestEnvironment.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.Environment; -class TestEnvironment +internal class TestEnvironment { public bool CaptureWebServerOutput { get; set; } diff --git a/dotnet/test/common/Environment/TestWebServer.cs b/dotnet/test/common/Environment/TestWebServer.cs index 51e2070688b53..14c47996340d9 100644 --- a/dotnet/test/common/Environment/TestWebServer.cs +++ b/dotnet/test/common/Environment/TestWebServer.cs @@ -27,23 +27,14 @@ namespace OpenQA.Selenium.Environment; -public class TestWebServer +public class TestWebServer(string projectRoot, TestWebServerConfig config) { private Process webserverProcess; private string standaloneAppserverPath; - private string projectRootPath; - private bool captureWebServerOutput; - private bool hideCommandPrompt; - private string port; - - public TestWebServer(string projectRoot, TestWebServerConfig config) - { - this.projectRootPath = projectRoot; - this.captureWebServerOutput = config.CaptureConsoleOutput; - this.hideCommandPrompt = config.HideCommandPromptWindow; - this.port = config.Port; - } + private bool captureWebServerOutput = config.CaptureConsoleOutput; + private readonly bool hideCommandPrompt = config.HideCommandPromptWindow; + private readonly string port = config.Port; public async Task StartAsync() { @@ -77,14 +68,14 @@ public async Task StartAsync() processArguments = $"run //java/test/org/openqa/selenium/environment:appserver {processArguments}"; // Override project root path to be exact selenium repo path, not 'bazel-bin' - projectRootPath = Path.Combine(AppContext.BaseDirectory, "../../../../../.."); + projectRoot = Path.Combine(AppContext.BaseDirectory, "../../../../../.."); } webserverProcess = new Process(); webserverProcess.StartInfo.FileName = processFileName; webserverProcess.StartInfo.Arguments = processArguments; - webserverProcess.StartInfo.WorkingDirectory = projectRootPath; + webserverProcess.StartInfo.WorkingDirectory = projectRoot; webserverProcess.StartInfo.UseShellExecute = !(hideCommandPrompt || captureWebServerOutput); webserverProcess.StartInfo.CreateNoWindow = hideCommandPrompt; @@ -131,7 +122,7 @@ public async Task StartAsync() output = webserverProcess.StandardOutput.ReadToEnd(); } - string errorMessage = string.Format("Could not start the test web server in {0} seconds.\nWorking directory: {1}\nProcess Args: {2}\nstdout: {3}\nstderr: {4}", timeout.TotalSeconds, projectRootPath, processArguments, output, error); + string errorMessage = string.Format("Could not start the test web server in {0} seconds.\nWorking directory: {1}\nProcess Args: {2}\nstdout: {3}\nstderr: {4}", timeout.TotalSeconds, projectRoot, processArguments, output, error); throw new TimeoutException(errorMessage); } diff --git a/dotnet/test/common/Environment/UrlBuilder.cs b/dotnet/test/common/Environment/UrlBuilder.cs index 35ec2fe27e059..d6082a0cadcb2 100644 --- a/dotnet/test/common/Environment/UrlBuilder.cs +++ b/dotnet/test/common/Environment/UrlBuilder.cs @@ -29,38 +29,26 @@ namespace OpenQA.Selenium.Environment; public class UrlBuilder { - string protocol; - string hostName; - string port; - string securePort; - string path; - string alternateHostName; - - public string AlternateHostName - { - get { return alternateHostName; } - } + private readonly string protocol; + private readonly string port; + private readonly string securePort; - public string HostName - { - get { return hostName; } - } + public string AlternateHostName { get; } - public string Path - { - get { return path; } - } + public string HostName { get; } + + public string Path { get; } public UrlBuilder(WebsiteConfig config) { protocol = config.Protocol; - hostName = config.HostName; + HostName = config.HostName; port = config.Port; securePort = config.SecurePort; - path = config.Folder; + Path = config.Folder; //Use the first IPv4 address that we find IPAddress ipAddress = IPAddress.Parse("127.0.0.1"); - foreach (IPAddress ip in Dns.GetHostEntry(hostName).AddressList) + foreach (IPAddress ip in Dns.GetHostEntry(HostName).AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { @@ -68,13 +56,13 @@ public UrlBuilder(WebsiteConfig config) break; } } - alternateHostName = ipAddress.ToString(); + AlternateHostName = ipAddress.ToString(); } public string LocalWhereIs(string page) { string location = string.Empty; - location = "http://localhost:" + port + "/" + path + "/" + page; + location = "http://localhost:" + port + "/" + Path + "/" + page; return location; } @@ -82,7 +70,7 @@ public string LocalWhereIs(string page) public string WhereIs(string page) { string location = string.Empty; - location = "http://" + hostName + ":" + port + "/" + path + "/" + page; + location = "http://" + HostName + ":" + port + "/" + Path + "/" + page; return location; } @@ -90,7 +78,7 @@ public string WhereIs(string page) public string WhereElseIs(string page) { string location = string.Empty; - location = "http://" + alternateHostName + ":" + port + "/" + path + "/" + page; + location = "http://" + AlternateHostName + ":" + port + "/" + Path + "/" + page; return location; } @@ -109,7 +97,7 @@ public string WhereIsViaNonLoopbackAddress(string page) } string location = string.Empty; - location = "http://" + hostNameAsIPAddress + ":" + port + "/" + path + "/" + page; + location = "http://" + hostNameAsIPAddress + ":" + port + "/" + Path + "/" + page; return location; } @@ -117,7 +105,7 @@ public string WhereIsViaNonLoopbackAddress(string page) public string WhereIsSecure(string page) { string location = string.Empty; - location = "https://" + hostName + ":" + securePort + "/" + path + "/" + page; + location = "https://" + HostName + ":" + securePort + "/" + Path + "/" + page; return location; } @@ -142,14 +130,14 @@ public string CreateInlinePage(InlinePage page) // The response string from the Java remote server has trailing null // characters. This is due to the fix for issue 288. - if (responseString.IndexOf('\0') >= 0) + if (responseString.Contains('\0')) { - responseString = responseString.Substring(0, responseString.IndexOf('\0')); + responseString = responseString[..responseString.IndexOf('\0')]; } if (responseString.Contains("localhost")) { - responseString = responseString.Replace("localhost", this.hostName); + responseString = responseString.Replace("localhost", HostName); } return responseString; diff --git a/dotnet/test/common/ExecutingJavascriptTest.cs b/dotnet/test/common/ExecutingJavascriptTest.cs index 1baa3cd7dba98..12a587233a05c 100644 --- a/dotnet/test/common/ExecutingJavascriptTest.cs +++ b/dotnet/test/common/ExecutingJavascriptTest.cs @@ -657,8 +657,7 @@ public void ShouldBeAbleToPassADictionaryAsAParameter() [Test] public void ShouldThrowAnExceptionWhenArgumentsWithStaleElementPassed() { - IJavaScriptExecutor executor = driver as IJavaScriptExecutor; - if (executor == null) + if (driver is not IJavaScriptExecutor executor) { return; } diff --git a/dotnet/test/common/GetLogsTest.cs b/dotnet/test/common/GetLogsTest.cs index 28d5c35ee5502..67f545d655008 100644 --- a/dotnet/test/common/GetLogsTest.cs +++ b/dotnet/test/common/GetLogsTest.cs @@ -24,6 +24,7 @@ namespace OpenQA.Selenium; +[Ignore("")] [TestFixture] [IgnoreBrowser(Browser.Firefox, "Firefox driver (when using Marionette/Geckodriver) does not support logs API")] [IgnoreBrowser(Browser.IE, "IE driver does not support logs API")] @@ -42,7 +43,7 @@ public void QuitDriver() } } - //[Test] + [Test] public void LogBufferShouldBeResetAfterEachGetLogCall() { ReadOnlyCollection logTypes = driver.Manage().Logs.AvailableLogTypes; @@ -58,7 +59,7 @@ public void LogBufferShouldBeResetAfterEachGetLogCall() } } - //[Test] + [Test] public void DifferentLogsShouldNotContainTheSameLogEntries() { driver.Url = simpleTestPage; @@ -81,7 +82,7 @@ public void DifferentLogsShouldNotContainTheSameLogEntries() } } - //[Test] + [Test] public void TurningOffLogShouldMeanNoLogMessages() { ReadOnlyCollection logTypes = driver.Manage().Logs.AvailableLogTypes; diff --git a/dotnet/test/common/I18Test.cs b/dotnet/test/common/I18Test.cs index 13fbfe465bb86..98f7e5a9ce8da 100644 --- a/dotnet/test/common/I18Test.cs +++ b/dotnet/test/common/I18Test.cs @@ -26,13 +26,13 @@ namespace OpenQA.Selenium; public class I18Test : DriverTestFixture { // The Hebrew word shalom (peace) encoded in order Shin (sh) Lamed (L) Vav (O) final-Mem (M). - private string shalom = "\u05E9\u05DC\u05D5\u05DD"; + private readonly string shalom = "\u05E9\u05DC\u05D5\u05DD"; // The Hebrew word tmunot (images) encoded in order Taf (t) Mem (m) Vav (u) Nun (n) Vav (o) Taf (t). - private string tmunot = "\u05EA\u05DE\u05D5\u05E0\u05D5\u05EA"; + private readonly string tmunot = "\u05EA\u05DE\u05D5\u05E0\u05D5\u05EA"; // This is the Chinese link text - private string linkText = "\u4E2D\u56FD\u4E4B\u58F0"; + private readonly string linkText = "\u4E2D\u56FD\u4E4B\u58F0"; [Test] public void ShouldBeAbleToReadChinese() diff --git a/dotnet/test/common/Interactions/BasicKeyboardInterfaceTest.cs b/dotnet/test/common/Interactions/BasicKeyboardInterfaceTest.cs index f5f2aadd04652..98c5faac65a16 100644 --- a/dotnet/test/common/Interactions/BasicKeyboardInterfaceTest.cs +++ b/dotnet/test/common/Interactions/BasicKeyboardInterfaceTest.cs @@ -32,8 +32,7 @@ public class BasicKeyboardInterfaceTest : DriverTestFixture public void Setup() { //new Actions(driver).SendKeys(Keys.Null).Perform(); - IActionExecutor actionExecutor = driver as IActionExecutor; - if (actionExecutor != null) + if (driver is IActionExecutor actionExecutor) { actionExecutor.ResetInputState(); } @@ -43,8 +42,7 @@ public void Setup() public void ReleaseModifierKeys() { //new Actions(driver).SendKeys(Keys.Null).Perform(); - IActionExecutor actionExecutor = driver as IActionExecutor; - if (actionExecutor != null) + if (driver is IActionExecutor actionExecutor) { actionExecutor.ResetInputState(); } @@ -220,8 +218,7 @@ public void SelectionSelectBySymbol() // inadvertent double-clicks with multiple actions calls), // so we call the "release actions" end point before // doing the second action. - IActionExecutor executor = driver as IActionExecutor; - if (executor != null) + if (driver is IActionExecutor executor) { executor.ResetInputState(); } @@ -263,8 +260,7 @@ public void SelectionSelectByWord() // inadvertent double-clicks with multiple actions calls), // so we call the "release actions" end point before // doing the second action. - IActionExecutor executor = driver as IActionExecutor; - if (executor != null) + if (driver is IActionExecutor executor) { executor.ResetInputState(); } diff --git a/dotnet/test/common/Interactions/BasicMouseInterfaceTest.cs b/dotnet/test/common/Interactions/BasicMouseInterfaceTest.cs index 9df7b2b5a1a8f..95f3502c0a44d 100644 --- a/dotnet/test/common/Interactions/BasicMouseInterfaceTest.cs +++ b/dotnet/test/common/Interactions/BasicMouseInterfaceTest.cs @@ -30,8 +30,7 @@ public class BasicMouseInterfaceTest : DriverTestFixture [SetUp] public void SetupTest() { - IActionExecutor actionExecutor = driver as IActionExecutor; - if (actionExecutor != null) + if (driver is IActionExecutor actionExecutor) { actionExecutor.ResetInputState(); } diff --git a/dotnet/test/common/Interactions/BasicWheelInterfaceTest.cs b/dotnet/test/common/Interactions/BasicWheelInterfaceTest.cs index 6b8566026a1f3..75e157c4e6573 100644 --- a/dotnet/test/common/Interactions/BasicWheelInterfaceTest.cs +++ b/dotnet/test/common/Interactions/BasicWheelInterfaceTest.cs @@ -29,8 +29,7 @@ public class BasicWheelInterfaceTest : DriverTestFixture [SetUp] public void SetupTest() { - IActionExecutor actionExecutor = driver as IActionExecutor; - if (actionExecutor != null) + if (driver is IActionExecutor actionExecutor) { actionExecutor.ResetInputState(); } diff --git a/dotnet/test/common/Interactions/CombinedInputActionsTest.cs b/dotnet/test/common/Interactions/CombinedInputActionsTest.cs index 0345118187f34..4509e22b9f4e1 100644 --- a/dotnet/test/common/Interactions/CombinedInputActionsTest.cs +++ b/dotnet/test/common/Interactions/CombinedInputActionsTest.cs @@ -33,8 +33,7 @@ public class CombinedInputActionsTest : DriverTestFixture public void Setup() { // new Actions(driver).SendKeys(Keys.Null).Perform(); - IActionExecutor actionExecutor = driver as IActionExecutor; - if (actionExecutor != null) + if (driver is IActionExecutor actionExecutor) { actionExecutor.ResetInputState(); } @@ -44,8 +43,7 @@ public void Setup() public void ReleaseModifierKeys() { // new Actions(driver).SendKeys(Keys.Null).Perform(); - IActionExecutor actionExecutor = driver as IActionExecutor; - if (actionExecutor != null) + if (driver is IActionExecutor actionExecutor) { actionExecutor.ResetInputState(); } diff --git a/dotnet/test/common/Interactions/DragAndDropTest.cs b/dotnet/test/common/Interactions/DragAndDropTest.cs index 61c7eaab7c422..f85d595df1dff 100644 --- a/dotnet/test/common/Interactions/DragAndDropTest.cs +++ b/dotnet/test/common/Interactions/DragAndDropTest.cs @@ -31,8 +31,7 @@ public class DragAndDropTest : DriverTestFixture [SetUp] public void SetupTest() { - IActionExecutor actionExecutor = driver as IActionExecutor; - if (actionExecutor != null) + if (driver is IActionExecutor actionExecutor) { actionExecutor.ResetInputState(); } @@ -114,7 +113,7 @@ public void DragAndDropElementWithOffsetInIframeAtBottom() [IgnoreBrowser(Browser.Safari, "Moving outside of view port throws exception in spec-compliant driver")] public void DragAndDropElementWithOffsetInScrolledDiv() { - if (TestUtilities.IsFirefox(driver) && TestUtilities.IsNativeEventsEnabled(driver)) + if (TestUtilities.IsFirefox(driver) && IsNativeEventsEnabled) { return; } diff --git a/dotnet/test/common/Internal/Logging/LogTest.cs b/dotnet/test/common/Internal/Logging/LogTest.cs index 841e66e500f1f..4f72a751c8cb8 100644 --- a/dotnet/test/common/Internal/Logging/LogTest.cs +++ b/dotnet/test/common/Internal/Logging/LogTest.cs @@ -248,7 +248,7 @@ public void ShouldCapturePreviousContextWhenCurrentFinishes() } } -class TestLogHandler : ILogHandler +internal class TestLogHandler : ILogHandler { public ILogHandler Clone() { diff --git a/dotnet/test/common/ProxySettingTest.cs b/dotnet/test/common/ProxySettingTest.cs index a52708a21fc7b..62c4296979737 100644 --- a/dotnet/test/common/ProxySettingTest.cs +++ b/dotnet/test/common/ProxySettingTest.cs @@ -149,8 +149,7 @@ public void CanUseAutoConfigFileThatOnlyProxiesCertainHosts() private void EnvironmentManagerDriverStarting(object sender, DriverStartingEventArgs e) { - InternetExplorerOptions ieOptions = e.Options as InternetExplorerOptions; - if (ieOptions != null) + if (e.Options is InternetExplorerOptions ieOptions) { ieOptions.EnsureCleanSession = true; } @@ -183,13 +182,11 @@ public override ICapabilities ToCapabilities() private class ProxyAutoConfigServer : IDisposable { - private int listenerPort; - private string hostName; - private string pacFileContent; + private readonly string pacFileContent; private bool disposedValue = false; // To detect redundant calls private bool keepRunning = true; private HttpListener listener; - private Thread listenerThread; + private readonly Thread listenerThread; public ProxyAutoConfigServer(string pacFileContent) : this(pacFileContent, "localhost") @@ -199,31 +196,35 @@ public ProxyAutoConfigServer(string pacFileContent) public ProxyAutoConfigServer(string pacFileContent, string hostName) { this.pacFileContent = pacFileContent; - this.hostName = hostName; + HostName = hostName; + Port = DetectEmptyPort(); + this.listenerThread = StartListeningThread(); + } - //get an empty port - TcpListener l = new TcpListener(IPAddress.Loopback, 0); - l.Start(); - this.listenerPort = ((IPEndPoint)l.LocalEndpoint).Port; - l.Stop(); + public string HostName { get; } - this.listenerThread = new Thread(this.Listen); - this.listenerThread.Start(); - } + public int Port { get; } - public string HostName + private static int DetectEmptyPort() { - get { return hostName; } + TcpListener l = new TcpListener(IPAddress.Loopback, 0); + l.Start(); + var port = ((IPEndPoint)l.LocalEndpoint).Port; + l.Stop(); + return port; } - public int Port + private Thread StartListeningThread() { - get { return listenerPort; } + var thread = new Thread(Listen); + thread.Start(); + return thread; } public void Dispose() { Dispose(true); + GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) @@ -241,9 +242,14 @@ protected virtual void Dispose(bool disposing) } } + ~ProxyAutoConfigServer() + { + Dispose(false); + } + private void ProcessContext(HttpListenerContext context) { - if (context.Request.Url.AbsoluteUri.ToLowerInvariant().Contains("proxy.pac")) + if (context.Request.Url.AbsoluteUri.Contains("proxy.pac", StringComparison.InvariantCultureIgnoreCase)) { byte[] pacFileBuffer = Encoding.ASCII.GetBytes(this.pacFileContent); context.Response.ContentType = "application/x-javascript-config"; @@ -258,7 +264,7 @@ private void ProcessContext(HttpListenerContext context) private void Listen() { listener = new HttpListener(); - listener.Prefixes.Add("http://" + this.HostName + ":" + this.listenerPort.ToString() + "/"); + listener.Prefixes.Add("http://" + this.HostName + ":" + Port.ToString() + "/"); listener.Start(); while (this.keepRunning) { @@ -276,10 +282,7 @@ private void Listen() private class ProxyServer { - private HttpProxyServer server; - private List uris = new List(); - int port; - string hostName = string.Empty; + private readonly List uris = new List(); public ProxyServer() : this("127.0.0.1") @@ -289,51 +292,39 @@ public ProxyServer() public ProxyServer(string hostName) { - this.hostName = hostName; - this.server = new HttpProxyServer(this.hostName, new HttpProxy()); - this.server.Start().WaitOne(); - this.port = this.server.ProxyEndPoint.Port; - // this.server.Log += OnServerLog; + HostName = hostName; + Server = new HttpProxyServer(HostName, new HttpProxy()); + Server.Start().WaitOne(); + Port = Server.ProxyEndPoint.Port; + // this.Server.Log += OnServerLog; } - public string BaseUrl - { - get { return string.Format("{0}:{1}", this.hostName, this.port); } - } + public string BaseUrl => string.Format("{0}:{1}", HostName, Port); - public HttpProxyServer Server - { - get { return this.server; } - } + public HttpProxyServer Server { get; } - public string HostName - { - get { return hostName; } - } + public string HostName { get; } = string.Empty; - public int Port - { - get { return port; } - } + public int Port { get; } public void EnableLogResourcesOnResponse() { - this.server.Proxy.OnResponseSent = this.LogRequestedResources; + Server.Proxy.OnResponseSent = this.LogRequestedResources; } public void DisableLogResourcesOnResponse() { - this.server.Proxy.OnResponseSent = null; + Server.Proxy.OnResponseSent = null; } public void EnableContentOverwriteOnRequest() { - this.server.Proxy.OnRequestReceived = this.OverwriteRequestedContent; + Server.Proxy.OnRequestReceived = this.OverwriteRequestedContent; } public void DisableContentOverwriteOnRequest() { - this.server.Proxy.OnRequestReceived = null; + Server.Proxy.OnRequestReceived = null; } public bool HasBeenCalled(string resourceName) @@ -343,8 +334,8 @@ public bool HasBeenCalled(string resourceName) public void Quit() { - this.server.Proxy.OnResponseSent = null; - this.server.Stop(); + Server.Proxy.OnResponseSent = null; + Server.Stop(); } public Proxy AsProxy() diff --git a/dotnet/test/common/StaleElementReferenceTest.cs b/dotnet/test/common/StaleElementReferenceTest.cs index a8b273cb7f349..3a733279d051b 100644 --- a/dotnet/test/common/StaleElementReferenceTest.cs +++ b/dotnet/test/common/StaleElementReferenceTest.cs @@ -62,18 +62,20 @@ public void RemovingAnElementDynamicallyFromTheDomShouldCauseAStaleRefException( driver.FindElement(By.Id("delete")).Click(); - bool wasStale = WaitFor(() => + Assert.That(() => { - try + WaitFor(() => { - string tagName = toBeDeleted.TagName; - return false; - } - catch (StaleElementReferenceException) - { - return true; - } - }, "Element did not become stale."); - Assert.That(wasStale, Is.True, "Element should be stale at this point"); + try + { + string tagName = toBeDeleted.TagName; + return false; + } + catch (StaleElementReferenceException) + { + return true; + } + }, "Element did not become stale."); + }, Throws.Nothing, "Element should be stale at this point"); } } diff --git a/dotnet/test/common/TakesScreenshotTest.cs b/dotnet/test/common/TakesScreenshotTest.cs index 6cf5825361bf1..ad3dcaf3e0470 100644 --- a/dotnet/test/common/TakesScreenshotTest.cs +++ b/dotnet/test/common/TakesScreenshotTest.cs @@ -38,8 +38,7 @@ public void SwitchToTop() [Test] public void GetScreenshotAsFile() { - ITakesScreenshot screenshotCapableDriver = driver as ITakesScreenshot; - if (screenshotCapableDriver == null) + if (driver is not ITakesScreenshot screenshotCapableDriver) { return; } @@ -57,8 +56,7 @@ public void GetScreenshotAsFile() [Test] public void GetScreenshotAsBase64() { - ITakesScreenshot screenshotCapableDriver = driver as ITakesScreenshot; - if (screenshotCapableDriver == null) + if (driver is not ITakesScreenshot screenshotCapableDriver) { return; } @@ -72,8 +70,7 @@ public void GetScreenshotAsBase64() [Test] public void GetScreenshotAsBinary() { - ITakesScreenshot screenshotCapableDriver = driver as ITakesScreenshot; - if (screenshotCapableDriver == null) + if (driver is not ITakesScreenshot screenshotCapableDriver) { return; } @@ -95,8 +92,7 @@ public void ShouldCaptureScreenshotOfCurrentViewport() Assert.Ignore("Skipping test: this framework can not process colors."); #endif - ITakesScreenshot screenshotCapableDriver = driver as ITakesScreenshot; - if (screenshotCapableDriver == null) + if (driver is not ITakesScreenshot screenshotCapableDriver) { return; } @@ -128,8 +124,7 @@ public void ShouldTakeScreenshotsOfAnElement() driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("screen/screen.html"); IWebElement element = driver.FindElement(By.Id("cell11")); - ITakesScreenshot screenshotCapableElement = element as ITakesScreenshot; - if (screenshotCapableElement == null) + if (element is not ITakesScreenshot screenshotCapableElement) { return; } @@ -154,8 +149,7 @@ public void ShouldCaptureScreenshotAtFramePage() Assert.Ignore("Skipping test: this framework can not process colors."); #endif - ITakesScreenshot screenshotCapableDriver = driver as ITakesScreenshot; - if (screenshotCapableDriver == null) + if (driver is not ITakesScreenshot screenshotCapableDriver) { return; } @@ -199,8 +193,7 @@ public void ShouldCaptureScreenshotAtIFramePage() Assert.Ignore("Skipping test: this framework can not process colors."); #endif - ITakesScreenshot screenshotCapableDriver = driver as ITakesScreenshot; - if (screenshotCapableDriver == null) + if (driver is not ITakesScreenshot screenshotCapableDriver) { return; } @@ -242,8 +235,7 @@ public void ShouldCaptureScreenshotAtFramePageAfterSwitching() Assert.Ignore("Skipping test: this framework can not process colors."); #endif - ITakesScreenshot screenshotCapableDriver = driver as ITakesScreenshot; - if (screenshotCapableDriver == null) + if (driver is not ITakesScreenshot screenshotCapableDriver) { return; } @@ -283,8 +275,7 @@ public void ShouldCaptureScreenshotAtIFramePageAfterSwitching() Assert.Ignore("Skipping test: this framework can not process colors."); #endif - ITakesScreenshot screenshotCapableDriver = driver as ITakesScreenshot; - if (screenshotCapableDriver == null) + if (driver is not ITakesScreenshot screenshotCapableDriver) { return; } diff --git a/dotnet/test/common/TestUtilities.cs b/dotnet/test/common/TestUtilities.cs index 28e543604d0ff..d56e59983467b 100644 --- a/dotnet/test/common/TestUtilities.cs +++ b/dotnet/test/common/TestUtilities.cs @@ -103,19 +103,4 @@ public static bool IsOldIE(IWebDriver driver) return false; } } - - public static bool IsNativeEventsEnabled(IWebDriver driver) - { - IHasCapabilities hasCaps = driver as IHasCapabilities; - if (hasCaps != null) - { - object cap = hasCaps.Capabilities.GetCapability(OpenQA.Selenium.CapabilityType.HasNativeEvents); - if (cap != null && cap is bool) - { - return (bool)cap; - } - } - - return false; - } } diff --git a/dotnet/test/common/TextPagesTest.cs b/dotnet/test/common/TextPagesTest.cs index be35bd3e820bb..7e89f0bbbc2cd 100644 --- a/dotnet/test/common/TextPagesTest.cs +++ b/dotnet/test/common/TextPagesTest.cs @@ -25,7 +25,7 @@ namespace OpenQA.Selenium; [TestFixture] public class TextPagesTest : DriverTestFixture { - private string textPage = EnvironmentManager.Instance.UrlBuilder.WhereIs("plain.txt"); + private readonly string textPage = EnvironmentManager.Instance.UrlBuilder.WhereIs("plain.txt"); [Test] public void ShouldBeAbleToLoadASimplePageOfText() diff --git a/dotnet/test/common/TimeoutDriverOptionsTest.cs b/dotnet/test/common/TimeoutDriverOptionsTest.cs index 9dd21b76e2b29..c26e252110dff 100644 --- a/dotnet/test/common/TimeoutDriverOptionsTest.cs +++ b/dotnet/test/common/TimeoutDriverOptionsTest.cs @@ -131,7 +131,7 @@ public void CanSetTimeout() Assert.That(driver.Manage().Timeouts().ImplicitWait, Is.EqualTo(expectedImplicitWaitTimeout)); } - class TestDriverOptions : DriverOptions + private class TestDriverOptions : DriverOptions { public override ICapabilities ToCapabilities() { diff --git a/dotnet/test/common/WebElementWrapper.cs b/dotnet/test/common/WebElementWrapper.cs index 3fdf9cc3e5b97..bc131fa17eb83 100644 --- a/dotnet/test/common/WebElementWrapper.cs +++ b/dotnet/test/common/WebElementWrapper.cs @@ -22,84 +22,77 @@ namespace OpenQA.Selenium { - public class WebElementWrapper : IWebElement, IWrapsElement + public class WebElementWrapper(IWebElement element) : IWebElement, IWrapsElement { - private readonly IWebElement _webElement; + public IWebElement WrappedElement { get; } = element; - public WebElementWrapper(IWebElement element) - { - _webElement = element; - } - - public IWebElement WrappedElement => _webElement; - - public string TagName => _webElement.TagName; + public string TagName => WrappedElement.TagName; - public string Text => _webElement.Text; + public string Text => WrappedElement.Text; - public bool Enabled => _webElement.Enabled; + public bool Enabled => WrappedElement.Enabled; - public bool Selected => _webElement.Selected; + public bool Selected => WrappedElement.Selected; - public Point Location => _webElement.Location; + public Point Location => WrappedElement.Location; - public Size Size => _webElement.Size; + public Size Size => WrappedElement.Size; - public bool Displayed => _webElement.Displayed; + public bool Displayed => WrappedElement.Displayed; public void Clear() { - _webElement.Clear(); + WrappedElement.Clear(); } public void Click() { - _webElement.Click(); + WrappedElement.Click(); } public IWebElement FindElement(By by) { - return _webElement.FindElement(by); + return WrappedElement.FindElement(by); } public ReadOnlyCollection FindElements(By by) { - return _webElement.FindElements(by); + return WrappedElement.FindElements(by); } public string GetAttribute(string attributeName) { - return _webElement.GetAttribute(attributeName); + return WrappedElement.GetAttribute(attributeName); } public string GetCssValue(string propertyName) { - return _webElement.GetCssValue(propertyName); + return WrappedElement.GetCssValue(propertyName); } public string GetDomAttribute(string attributeName) { - return _webElement.GetDomAttribute(attributeName); + return WrappedElement.GetDomAttribute(attributeName); } public string GetDomProperty(string propertyName) { - return _webElement.GetDomProperty(propertyName); + return WrappedElement.GetDomProperty(propertyName); } public ISearchContext GetShadowRoot() { - return _webElement.GetShadowRoot(); + return WrappedElement.GetShadowRoot(); } public void SendKeys(string text) { - _webElement.SendKeys(text); + WrappedElement.SendKeys(text); } public void Submit() { - _webElement.Submit(); + WrappedElement.Submit(); } } } diff --git a/dotnet/test/firefox/FirefoxDriverTest.cs b/dotnet/test/firefox/FirefoxDriverTest.cs index 102fc3d94c301..83e1ecd8ec560 100644 --- a/dotnet/test/firefox/FirefoxDriverTest.cs +++ b/dotnet/test/firefox/FirefoxDriverTest.cs @@ -29,7 +29,8 @@ namespace OpenQA.Selenium.Firefox; [TestFixture] public class FirefoxDriverTest : DriverTestFixture { - //[Test] + [Ignore("")] + [Test] public void ShouldContinueToWorkIfUnableToFindElementById() { driver.Url = formsPage; @@ -42,7 +43,8 @@ public void ShouldContinueToWorkIfUnableToFindElementById() driver.Url = xhtmlTestPage; } - //[Test] + [Ignore("")] + [Test] public void ShouldWaitUntilBrowserHasClosedProperly() { driver.Url = simpleTestPage; @@ -61,7 +63,8 @@ public void ShouldWaitUntilBrowserHasClosedProperly() Assert.That(seenText, Is.EqualTo(expectedText)); } - //[Test] + [Ignore("")] + [Test] public void ShouldBeAbleToStartMoreThanOneInstanceOfTheFirefoxDriverSimultaneously() { IWebDriver secondDriver = new FirefoxDriver(); @@ -76,7 +79,8 @@ public void ShouldBeAbleToStartMoreThanOneInstanceOfTheFirefoxDriverSimultaneous secondDriver.Quit(); } - //[Test] + [Ignore("")] + [Test] public void ShouldBeAbleToStartANamedProfile() { FirefoxProfile profile = new FirefoxProfileManager().GetProfile("default"); @@ -93,7 +97,8 @@ public void ShouldBeAbleToStartANamedProfile() } } - //[Test] + [Ignore("")] + [Test] public void ShouldRemoveProfileAfterExit() { FirefoxProfile profile = new FirefoxProfile(); @@ -106,7 +111,8 @@ public void ShouldRemoveProfileAfterExit() Assert.That(profileLocation, Does.Not.Exist); } - //[Test] + [Ignore("")] + [Test] [NeedsFreshDriver(IsCreatedBeforeTest = true, IsCreatedAfterTest = true)] public void FocusRemainsInOriginalWindowWhenOpeningNewWindow() { @@ -130,7 +136,8 @@ public void FocusRemainsInOriginalWindowWhenOpeningNewWindow() Assert.That(keyReporter.GetAttribute("value"), Is.EqualTo("ABC DEF")); } - //[Test] + [Ignore("")] + [Test] [NeedsFreshDriver(IsCreatedBeforeTest = true, IsCreatedAfterTest = true)] public void SwitchingWindowShouldSwitchFocus() { @@ -175,7 +182,8 @@ public void SwitchingWindowShouldSwitchFocus() Assert.That(keyReporter2.GetAttribute("value"), Is.EqualTo("QWERTY")); } - //[Test] + [Ignore("")] + [Test] [NeedsFreshDriver(IsCreatedBeforeTest = true, IsCreatedAfterTest = true)] public void ClosingWindowAndSwitchingToOriginalSwitchesFocus() { @@ -214,7 +222,8 @@ public void ClosingWindowAndSwitchingToOriginalSwitchesFocus() Assert.That(keyReporter.GetAttribute("value"), Is.EqualTo("ABC DEF")); } - //[Test] + [Ignore("")] + [Test] public void CanBlockInvalidSslCertificates() { FirefoxProfile profile = new FirefoxProfile(); @@ -243,7 +252,8 @@ public void CanBlockInvalidSslCertificates() } } - //[Test] + [Ignore("")] + [Test] public void ShouldAllowUserToSuccessfullyOverrideTheHomePage() { FirefoxProfile profile = new FirefoxProfile(); diff --git a/dotnet/test/ie/IeSpecificTests.cs b/dotnet/test/ie/IeSpecificTests.cs index c0077e7f2e44b..2c8f1e5a39bd5 100644 --- a/dotnet/test/ie/IeSpecificTests.cs +++ b/dotnet/test/ie/IeSpecificTests.cs @@ -27,10 +27,11 @@ namespace OpenQA.Selenium.IE; +[Ignore("")] [TestFixture] public class IeSpecificTests : DriverTestFixture { - //[Test] + [Test] public void KeysTest() { List keyComboNames = new List() @@ -121,7 +122,7 @@ public void KeysTest() Assert.That(passed, errors); } - //[Test] + [Test] public void InputOnChangeAlert() { driver.Url = alertsPage; @@ -130,7 +131,7 @@ public void InputOnChangeAlert() alert.Accept(); } - //[Test] + [Test] public void ScrollingFrameTest() { try @@ -156,7 +157,7 @@ public void ScrollingFrameTest() } } - //[Test] + [Test] public void AlertSelectTest() { driver.Url = alertsPage; @@ -165,7 +166,7 @@ public void AlertSelectTest() alert.Accept(); } - //[Test] + [Test] public void ShouldBeAbleToBrowseTransformedXml() { driver.Url = xhtmlTestPage; @@ -183,7 +184,7 @@ public void ShouldBeAbleToBrowseTransformedXml() Assert.That(driver.Title, Is.EqualTo("We Arrive Here")); } - //[Test] + [Test] public void ShouldBeAbleToStartMoreThanOneInstanceOfTheIEDriverSimultaneously() { IWebDriver secondDriver = new InternetExplorerDriver(); @@ -198,7 +199,7 @@ public void ShouldBeAbleToStartMoreThanOneInstanceOfTheIEDriverSimultaneously() secondDriver.Quit(); } - //[Test] + [Test] public void ShouldPropagateSessionCookies() { driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("sessionCookie.html"); @@ -215,7 +216,7 @@ public void ShouldPropagateSessionCookies() Assert.That(bodyStyle, Does.Contain("BACKGROUND-COLOR: #80ffff").Or.Contain("background-color: rgb(128, 255, 255)")); } - //[Test] + [Test] public void ShouldHandleShowModalDialogWindows() { driver.Url = alertsPage; @@ -251,7 +252,7 @@ public void ShouldHandleShowModalDialogWindows() driver.SwitchTo().Window(originalWindowHandle); } - //[Test] + [Test] public void ScrollTest() { driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scroll.html"); @@ -261,7 +262,7 @@ public void ScrollTest() Assert.That(driver.FindElement(By.Id("clicked")).Text, Is.EqualTo("line1")); } - //[Test] + [Test] public void ShouldNotScrollOverflowElementsWhichAreVisible() { driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scroll2.html"); @@ -271,7 +272,7 @@ public void ShouldNotScrollOverflowElementsWhichAreVisible() Assert.That(((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].scrollTop;", list), Is.Zero, "Should not have scrolled"); } - //[Test] + [Test] public void ShouldNotScrollIfAlreadyScrolledAndElementIsInView() { driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scroll3.html"); @@ -281,7 +282,7 @@ public void ShouldNotScrollIfAlreadyScrolledAndElementIsInView() Assert.That(GetScrollTop(), Is.EqualTo(scrollTop)); } - //[Test] + [Test] public void ShouldBeAbleToHandleCascadingModalDialogs() { driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("modal_dialogs/modalindex.html"); @@ -316,7 +317,7 @@ public void ShouldBeAbleToHandleCascadingModalDialogs() driver.SwitchTo().Window(parentHandle); } - //[Test] + [Test] public void ShouldBeAbleToHandleCascadingModalDialogsLaunchedWithJavaScriptLinks() { driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("modal_dialogs/modalindex.html"); @@ -352,7 +353,7 @@ public void ShouldBeAbleToHandleCascadingModalDialogsLaunchedWithJavaScriptLinks driver.SwitchTo().Window(parentHandle); } - //[Test] + [Test] public void TestInvisibleZOrder() { driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("elementObscuredByInvisibleElement.html"); diff --git a/dotnet/test/support/UI/SelectBrowserTests.cs b/dotnet/test/support/UI/SelectBrowserTests.cs index 0fc4962e67a29..59ca1df5634b7 100644 --- a/dotnet/test/support/UI/SelectBrowserTests.cs +++ b/dotnet/test/support/UI/SelectBrowserTests.cs @@ -161,7 +161,7 @@ public void ShouldReturnFirstSelectedOption() Assert.That(firstSelected.Text, Is.EqualTo("Eggs")); } - // [Test] + //[Test] // [ExpectedException(typeof(NoSuchElementException))] // The .NET bindings do not have a "FirstSelectedOption" property, // and no one has asked for it to this point. Given that, this test