Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dotnet/test/common/AlertsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public void ShouldNotHandleAlertInAnotherWindow()
IWebElement el = driver.FindElement(By.Id("open-new-window"));
WaitFor<IAlert>(AlertToBePresent, TimeSpan.FromSeconds(5), "No alert found");
},
Throws.TypeOf<WebDriverException>());
Throws.InstanceOf<WebDriverException>());

}
finally
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Browser/BrowserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace OpenQA.Selenium.BiDi.Browser;

class BrowserTest : BiDiTestFixture
internal class BrowserTest : BiDiTestFixture
{
[Test]
public async Task CanCreateUserContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace OpenQA.Selenium.BiDi.BrowsingContext;

class BrowsingContextEventsTest : BiDiTestFixture
internal class BrowsingContextEventsTest : BiDiTestFixture
{
[Test]
[IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace OpenQA.Selenium.BiDi.BrowsingContext;

class BrowsingContextTest : BiDiTestFixture
internal class BrowsingContextTest : BiDiTestFixture
{
[Test]
public async Task CanCreateNewTab()
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Emulation/EmulationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace OpenQA.Selenium.BiDi.Emulation;

class EmulationTest : BiDiTestFixture
internal class EmulationTest : BiDiTestFixture
{
[Test]
[IgnoreBrowser(Selenium.Browser.Firefox, "Not supported yet?")]
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Input/CombinedInputActionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace OpenQA.Selenium.BiDi.Input;

class CombinedInputActionsTest : BiDiTestFixture
internal class CombinedInputActionsTest : BiDiTestFixture
{
//[Test]
public async Task Paint()
Expand Down
4 changes: 2 additions & 2 deletions dotnet/test/common/BiDi/Input/SetFilesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Log/LogTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace OpenQA.Selenium.BiDi.Log;

class LogTest : BiDiTestFixture
internal class LogTest : BiDiTestFixture
{
[Test]
public async Task CanListenToConsoleLog()
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Network/NetworkEventsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace OpenQA.Selenium.BiDi.Network;

class NetworkEventsTest : BiDiTestFixture
internal class NetworkEventsTest : BiDiTestFixture
{
[Test]
public async Task CanListenToBeforeRequestSentEvent()
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Network/NetworkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace OpenQA.Selenium.BiDi.Network;

class NetworkTest : BiDiTestFixture
internal class NetworkTest : BiDiTestFixture
{
[Test]
public async Task CanAddDataCollector()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace OpenQA.Selenium.BiDi.Script;

class CallFunctionLocalValueTest : BiDiTestFixture
internal class CallFunctionLocalValueTest : BiDiTestFixture
{
[Test]
public async Task CanCallFunctionWithArgumentUndefined()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace OpenQA.Selenium.BiDi.Script;

class CallFunctionParameterTest : BiDiTestFixture
internal class CallFunctionParameterTest : BiDiTestFixture
{
[Test]
public async Task CanCallFunctionWithDeclaration()
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Script/EvaluateParametersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace OpenQA.Selenium.BiDi.Script;

class EvaluateParametersTest : BiDiTestFixture
internal class EvaluateParametersTest : BiDiTestFixture
{
[Test]
public async Task CanEvaluateScript()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace OpenQA.Selenium.BiDi.Script;

class LocalValueConversionTests
internal class LocalValueConversionTests
{
[Test]
public void CanConvertNullBoolToLocalValue()
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Script/ScriptCommandsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace OpenQA.Selenium.BiDi.Script;

class ScriptCommandsTest : BiDiTestFixture
internal class ScriptCommandsTest : BiDiTestFixture
{
[Test]
public async Task CanGetAllRealms()
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Script/ScriptEventsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace OpenQA.Selenium.BiDi.Script;

class ScriptEventsTest : BiDiTestFixture
internal class ScriptEventsTest : BiDiTestFixture
{
[Test]
public async Task CanListenToChannelMessage()
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Storage/StorageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace OpenQA.Selenium.BiDi.Storage;

class StorageTest : BiDiTestFixture
internal class StorageTest : BiDiTestFixture
{
[Test]
public async Task CanGetCookieByName()
Expand Down
4 changes: 2 additions & 2 deletions dotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions dotnet/test/common/CookieImplementationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/CorrectEventFiringTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" };
}
Original file line number Diff line number Diff line change
Expand Up @@ -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" };
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,5 @@ public StableChannelChromeDriver(ChromeDriverService service, ChromeOptions opti
{
}

public static ChromeOptions DefaultOptions
{
get { return new ChromeOptions(); }
}
public static ChromeOptions DefaultOptions => new ChromeOptions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
41 changes: 9 additions & 32 deletions dotnet/test/common/CustomTestAttributes/IgnoreBrowserAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Attribute> ignoreAttributes = new List<Attribute>();
IgnoreBrowserAttribute[] ignoreAttributes;
if (test.IsSuite)
{
Attribute[] ignoreClassAttributes = test.TypeInfo.GetCustomAttributes<IgnoreBrowserAttribute>(true);
if (ignoreClassAttributes.Length > 0)
{
ignoreAttributes.AddRange(ignoreClassAttributes);
}
ignoreAttributes = test.TypeInfo.GetCustomAttributes<IgnoreBrowserAttribute>(true);
}
else
{
IgnoreBrowserAttribute[] ignoreMethodAttributes = test.Method.GetCustomAttributes<IgnoreBrowserAttribute>(true);
if (ignoreMethodAttributes.Length > 0)
{
ignoreAttributes.AddRange(ignoreMethodAttributes);
}
ignoreAttributes = test.Method.GetCustomAttributes<IgnoreBrowserAttribute>(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() + ".";
Expand All @@ -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);
}
}
}
Expand Down
Loading