Skip to content

Commit f79148f

Browse files
committed
Updating .NET tests to use NUnit 3.0
1 parent 6b496e6 commit f79148f

File tree

235 files changed

+108774
-13090
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+108774
-13090
lines changed

dotnet/src/webdriver/IE/InternetExplorerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public class InternetExplorerOptions
133133
private bool ignoreProtectedModeSettings;
134134
private bool ignoreZoomLevel;
135135
private bool enableNativeEvents = true;
136-
private bool requireWindowFocus;
136+
private bool requireWindowFocus = true;
137137
private bool enablePersistentHover = true;
138138
private bool forceCreateProcessApi;
139139
private bool forceShellWindowsApi;

dotnet/test/chrome/WebDriver.Chrome.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
5454
</PropertyGroup>
5555
<ItemGroup>
56-
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
56+
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
5757
<SpecificVersion>False</SpecificVersion>
58-
<HintPath>..\..\..\third_party\dotnet\nunit-2.6.2\framework\nunit.framework.dll</HintPath>
58+
<HintPath>..\..\..\third_party\dotnet\nunit-3.0.1\nunit.framework.dll</HintPath>
5959
</Reference>
6060
<Reference Include="System" />
6161
<Reference Include="System.Core">

dotnet/test/chrome/WebDriver.Chrome.Tests.nunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<NUnitProject>
22
<Settings appbase="." />
3-
<Config name="Default" binpathtype="Auto">
3+
<Config name="Default" binpathtype="Auto" configfile="WebDriver.Chrome.Tests.config">
44
<assembly path="WebDriver.Common.Tests.dll" />
55
<assembly path="WebDriver.Chrome.Tests.dll" />
66
</Config>

dotnet/test/common/AlertsTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace OpenQA.Selenium
1111
{
12+
[IgnoreBrowser(Browser.Edge)]
1213
[TestFixture]
1314
public class AlertsTest : DriverTestFixture
1415
{
@@ -269,7 +270,6 @@ public void ShouldAllowTheUserToGetTheTextOfAPrompt()
269270
[IgnoreBrowser(Browser.Remote)]
270271
[IgnoreBrowser(Browser.Safari)]
271272
[IgnoreBrowser(Browser.WindowsPhone, "Alert handling not yet implemented on Windows Phone")]
272-
[ExpectedException(typeof(NoAlertPresentException))]
273273
public void AlertShouldNotAllowAdditionalCommandsIfDimissed()
274274
{
275275
driver.Url = alertsPage;
@@ -278,7 +278,8 @@ public void AlertShouldNotAllowAdditionalCommandsIfDimissed()
278278

279279
IAlert alert = WaitFor<IAlert>(AlertToBePresent, "No alert found");
280280
alert.Dismiss();
281-
string text = alert.Text;
281+
string text;
282+
Assert.Throws<NoAlertPresentException>(() => text = alert.Text);
282283
}
283284

284285
[Test]
@@ -334,12 +335,11 @@ public void ShouldAllowUsersToAcceptAnAlertInANestedFrame()
334335
[IgnoreBrowser(Browser.Remote)]
335336
[IgnoreBrowser(Browser.Safari)]
336337
[IgnoreBrowser(Browser.WindowsPhone, "Alert handling not yet implemented on Windows Phone")]
337-
[ExpectedException(typeof(NoAlertPresentException))]
338338
public void SwitchingToMissingAlertThrows()
339339
{
340340
driver.Url = alertsPage;
341341

342-
AlertToBePresent();
342+
Assert.Throws<NoAlertPresentException>(() => AlertToBePresent());
343343
}
344344

345345
[Test]
@@ -622,7 +622,7 @@ public void IncludesAlertTextInUnhandledAlertException()
622622
}
623623

624624
[Test]
625-
[NeedsFreshDriver(AfterTest = true)]
625+
[NeedsFreshDriver(IsCreatedAfterTest = true)]
626626
[IgnoreBrowser(Browser.Opera)]
627627
[IgnoreBrowser(Browser.PhantomJS, "Alert commands not yet implemented in GhostDriver")]
628628
[IgnoreBrowser(Browser.Safari)]
@@ -661,7 +661,7 @@ public void ShouldHandleOnBeforeUnloadAlert()
661661
[IgnoreBrowser(Browser.PhantomJS, "Alert commands not yet implemented in GhostDriver")]
662662
[IgnoreBrowser(Browser.Safari)]
663663
[IgnoreBrowser(Browser.WindowsPhone, "Alert handling not yet implemented on Windows Phone")]
664-
[NeedsFreshDriver(AfterTest = true)]
664+
[NeedsFreshDriver(IsCreatedAfterTest = true)]
665665
public void ShouldHandleOnBeforeUnloadAlertAtClose()
666666
{
667667
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("pageWithOnBeforeUnloadMessage.html");

dotnet/test/common/AssemblyTeardown.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public AssemblyTeardown()
1111
{
1212
}
1313

14-
[SetUp]
14+
[OneTimeSetUp]
1515
public void RunBeforeAnyTest()
1616
{
1717
EnvironmentManager.Instance.WebServer.Start();
@@ -21,7 +21,7 @@ public void RunBeforeAnyTest()
2121
}
2222
}
2323

24-
[TearDown]
24+
[OneTimeTearDown]
2525
public void RunAfterAnyTests()
2626
{
2727
EnvironmentManager.Instance.CloseCurrentDriver();

dotnet/test/common/ChildrenFindingTest.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ public void FindingDotSlashElementsOnElementByXPathShouldFindNotTopLevelElements
4040
}
4141

4242
[Test]
43-
[ExpectedException(typeof(NoSuchElementException))]
4443
public void FindElementByXPathWhenNoMatch()
4544
{
4645
driver.Url = nestedPage;
4746
IWebElement element = driver.FindElement(By.Name("form2"));
48-
element.FindElement(By.XPath("select/x"));
47+
Assert.Throws<NoSuchElementException>(() => element.FindElement(By.XPath("select/x")));
4948
}
5049

5150
[Test]
@@ -107,12 +106,11 @@ public void FindElementByIdWhenMultipleMatchesExist()
107106

108107

109108
[Test]
110-
[ExpectedException(typeof(NoSuchElementException))]
111109
public void FindElementByIdWhenNoMatchInContext()
112110
{
113111
driver.Url = nestedPage;
114112
IWebElement element = driver.FindElement(By.Id("test_id_div"));
115-
element.FindElement(By.Id("test_id_out"));
113+
Assert.Throws<NoSuchElementException>(() => element.FindElement(By.Id("test_id_out")));
116114
}
117115

118116

dotnet/test/common/ClearTest.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,22 @@ public void WritableTextInputShouldClear()
2020

2121
[Test]
2222
[IgnoreBrowser(Browser.Android, "Untested feature")]
23-
[ExpectedException(typeof(InvalidElementStateException))]
2423
public void TextInputShouldNotClearWhenDisabled()
2524
{
2625
driver.Url = readOnlyPage;
2726
IWebElement element = driver.FindElement(By.Id("textInputnotenabled"));
2827
Assert.IsFalse(element.Enabled);
29-
element.Clear();
28+
Assert.Throws<InvalidElementStateException>(() => element.Clear());
3029
}
3130

3231
[Test]
3332
[IgnoreBrowser(Browser.Android, "Untested feature")]
3433
[IgnoreBrowser(Browser.Opera, "Untested feature")]
35-
[ExpectedException(typeof(InvalidElementStateException))]
3634
public void TextInputShouldNotClearWhenReadOnly()
3735
{
3836
driver.Url = readOnlyPage;
3937
IWebElement element = driver.FindElement(By.Id("readOnlyTextInput"));
40-
element.Clear();
38+
Assert.Throws<InvalidElementStateException>(() => element.Clear());
4139
}
4240

4341
[Test]
@@ -52,23 +50,21 @@ public void WritableTextAreaShouldClear()
5250

5351
[Test]
5452
[IgnoreBrowser(Browser.Android, "Untested feature")]
55-
[ExpectedException(typeof(InvalidElementStateException))]
5653
public void TextAreaShouldNotClearWhenDisabled()
5754
{
5855
driver.Url = readOnlyPage;
5956
IWebElement element = driver.FindElement(By.Id("textAreaNotenabled"));
60-
element.Clear();
57+
Assert.Throws<InvalidElementStateException>(() => element.Clear());
6158
}
6259

6360
[Test]
6461
[IgnoreBrowser(Browser.Android, "Untested feature")]
6562
[IgnoreBrowser(Browser.Opera, "Untested feature")]
66-
[ExpectedException(typeof(InvalidElementStateException))]
6763
public void TextAreaShouldNotClearWhenReadOnly()
6864
{
6965
driver.Url = readOnlyPage;
7066
IWebElement element = driver.FindElement(By.Id("textAreaReadOnly"));
71-
element.Clear();
67+
Assert.Throws<InvalidElementStateException>(() => element.Clear());
7268
}
7369

7470
[Test]

dotnet/test/common/ClickScrollingTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ public void ShouldBeAbleToClickElementThatIsOutOfViewInAFrame()
161161
}
162162

163163
[Test]
164-
[ExpectedException]
165164
[Ignore("All tested browses scroll non-scrollable frames")]
166165
public void ShouldNotBeAbleToClickElementThatIsOutOfViewInANonScrollableFrame()
167166
{
@@ -170,7 +169,7 @@ public void ShouldNotBeAbleToClickElementThatIsOutOfViewInANonScrollableFrame()
170169
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/page_with_non_scrolling_frame.html");
171170
driver.SwitchTo().Frame("scrolling_frame");
172171
IWebElement element = driver.FindElement(By.Name("scroll_checkbox"));
173-
element.Click();
172+
Assert.Throws<WebDriverException>(() => element.Click());
174173
}
175174
finally
176175
{

dotnet/test/common/ClickTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void ShouldSetRelatedTargetForMouseOver()
144144

145145
[Test]
146146
[Category("JavaScript")]
147-
[NeedsFreshDriver(AfterTest = true)]
147+
[NeedsFreshDriver(IsCreatedAfterTest = true)]
148148
[IgnoreBrowser(Browser.IPhone, "Doesn't support multiple windows")]
149149
[IgnoreBrowser(Browser.WindowsPhone, "Doesn't support multiple windows")]
150150
[IgnoreBrowser(Browser.Opera, "Doesn't support multiple windows")]

dotnet/test/common/CookieImplementationTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ public void ShouldAddCookieToCurrentDomainAndPath()
629629
}
630630

631631
[Test]
632-
[ExpectedException(typeof(WebDriverException))]
633632
public void ShouldNotShowCookieAddedToDifferentDomain()
634633
{
635634
if (!CheckIsOnValidHostNameForCookieTests())
@@ -640,7 +639,7 @@ public void ShouldNotShowCookieAddedToDifferentDomain()
640639
driver.Url = macbethPage;
641640
IOptions options = driver.Manage();
642641
Cookie cookie = new Cookie("Bart", "Simpson", EnvironmentManager.Instance.UrlBuilder.HostName + ".com", EnvironmentManager.Instance.UrlBuilder.Path, null);
643-
options.Cookies.AddCookie(cookie);
642+
Assert.Throws<WebDriverException>(() => options.Cookies.AddCookie(cookie));
644643
ReadOnlyCollection<Cookie> cookies = options.Cookies.AllCookies;
645644
Assert.IsFalse(cookies.Contains(cookie), "Invalid cookie was returned");
646645
}

0 commit comments

Comments
 (0)