Skip to content

Commit 858b98d

Browse files
committed
[dotnet] update and fix tests
1 parent 695f83a commit 858b98d

18 files changed

+141
-550
lines changed

‎dotnet/src/webdriver/Cookie.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,12 @@ public Cookie(string name, string value, string domain, string path, DateTime? e
112112
/// <param name="domain">The domain of the cookie.</param>
113113
/// <param name="path">The path of the cookie.</param>
114114
/// <param name="expiry">The expiration date of the cookie.</param>
115-
/// <param name="isSecure"><see langword="true"/> if the cookie is secure; otherwise <see langword="false"/></param>
115+
/// <param name="secure"><see langword="true"/> if the cookie is secure; otherwise <see langword="false"/></param>
116116
/// <param name="isHttpOnly"><see langword="true"/> if the cookie is an HTTP-only cookie; otherwise <see langword="false"/></param>
117117
/// <param name="sameSite">The SameSite value of cookie.</param>
118118
/// <exception cref="ArgumentException">If the name and value are both an empty string,
119-
/// or if the name contains a semi-colon.</exception>
119+
/// if the name contains a semi-colon, or if same site value is not valid.</exception>
120120
/// <exception cref="ArgumentNullException">If the name, value or currentUrl is <see langword="null"/>.</exception>
121-
/// <exception cref="ArgumentNullException">If the same site value is not valid or same site value is "None" but secure is set to false.</exception>
122121
public Cookie(string name, string value, string domain, string path, DateTime? expiry, bool secure, bool isHttpOnly, string sameSite)
123122
{
124123
if (name == null)

‎dotnet/test/common/AlertsTest.cs

Lines changed: 1 addition & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -64,38 +64,6 @@ public void ShouldAllowUsersToAcceptAnAlertWithNoTextManually()
6464
Assert.AreEqual("Testing Alerts", driver.Title);
6565
}
6666

67-
[Test]
68-
[IgnoreBrowser(Browser.Chrome, "This is the correct behavior, for the SwitchTo call to throw if it happens before the setTimeout call occurs in the browser and the alert is displayed.")]
69-
[IgnoreBrowser(Browser.Edge, "This is the correct behavior, for the SwitchTo call to throw if it happens before the setTimeout call occurs in the browser and the alert is displayed.")]
70-
[IgnoreBrowser(Browser.EdgeLegacy, "This is the correct behavior, for the SwitchTo call to throw if it happens before the setTimeout call occurs in the browser and the alert is displayed.")]
71-
[IgnoreBrowser(Browser.IE, "This is the correct behavior, for the SwitchTo call to throw if it happens before the setTimeout call occurs in the browser and the alert is displayed.")]
72-
[IgnoreBrowser(Browser.Firefox, "This is the correct behavior, for the SwitchTo call to throw if it happens before the setTimeout call occurs in the browser and the alert is displayed.")]
73-
[IgnoreBrowser(Browser.Safari, "This is the correct behavior, for the SwitchTo call to throw if it happens before the setTimeout call occurs in the browser and the alert is displayed.")]
74-
public void ShouldGetTextOfAlertOpenedInSetTimeout()
75-
{
76-
driver.Url = EnvironmentManager.Instance.UrlBuilder.CreateInlinePage(new InlinePage()
77-
.WithTitle("Testing Alerts")
78-
.WithScripts(
79-
"function slowAlert() { window.setTimeout(function(){ alert('Slow'); }, 200); }")
80-
.WithBody(
81-
"<a href='#' id='slow-alert' onclick='slowAlert();'>click me</a>"));
82-
83-
driver.FindElement(By.Id("slow-alert")).Click();
84-
85-
// DO NOT WAIT OR SLEEP HERE.
86-
// This is a regression test for a bug where only the first switchTo call would throw,
87-
// and only if it happens before the alert actually loads.
88-
IAlert alert = driver.SwitchTo().Alert();
89-
try
90-
{
91-
Assert.AreEqual("Slow", alert.Text);
92-
}
93-
finally
94-
{
95-
alert.Accept();
96-
}
97-
}
98-
9967
[Test]
10068
public void ShouldAllowUsersToDismissAnAlertManually()
10169
{
@@ -446,86 +414,6 @@ public void ShouldNotHandleAlertInAnotherWindow()
446414
}
447415
}
448416

449-
[Test]
450-
[IgnoreBrowser(Browser.Firefox, "After version 27, Firefox does not trigger alerts on unload.")]
451-
[IgnoreBrowser(Browser.Chrome, "Chrome does not trigger alerts on unload.")]
452-
[IgnoreBrowser(Browser.Edge, "Edge does not trigger alerts on unload.")]
453-
[IgnoreBrowser(Browser.Safari, "Safari does not trigger alerts on unload.")]
454-
public void ShouldHandleAlertOnPageUnload()
455-
{
456-
string pageWithOnBeforeUnload = EnvironmentManager.Instance.UrlBuilder.CreateInlinePage(new InlinePage()
457-
.WithOnBeforeUnload("return \"onunload\";")
458-
.WithBody("<p>Page with onbeforeunload event handler</p>"));
459-
driver.Url = EnvironmentManager.Instance.UrlBuilder.CreateInlinePage(new InlinePage()
460-
.WithBody(string.Format("<a id='open-page-with-onunload-alert' href='{0}'>open new page</a>", pageWithOnBeforeUnload)));
461-
462-
IWebElement element = WaitFor<IWebElement>(ElementToBePresent(By.Id("open-page-with-onunload-alert")), "Could not find element with id 'open-page-with-onunload-alert'");
463-
element.Click();
464-
driver.Navigate().Back();
465-
466-
IAlert alert = WaitFor<IAlert>(AlertToBePresent, "No alert found");
467-
string value = alert.Text;
468-
alert.Accept();
469-
470-
Assert.AreEqual("onunload", value);
471-
element = WaitFor<IWebElement>(ElementToBePresent(By.Id("open-page-with-onunload-alert")), "Could not find element with id 'open-page-with-onunload-alert'");
472-
WaitFor(ElementTextToEqual(element, "open new page"), "Element text was not 'open new page'");
473-
}
474-
475-
[Test]
476-
[IgnoreBrowser(Browser.Chrome, "Chrome does not implicitly handle onBeforeUnload alert")]
477-
[IgnoreBrowser(Browser.Edge, "Edge does not implicitly handle onBeforeUnload alert")]
478-
public void ShouldImplicitlyHandleAlertOnPageBeforeUnload()
479-
{
480-
string blank = EnvironmentManager.Instance.UrlBuilder.CreateInlinePage(new InlinePage().WithTitle("Success"));
481-
driver.Url = EnvironmentManager.Instance.UrlBuilder.CreateInlinePage(new InlinePage()
482-
.WithTitle("Page with onbeforeunload handler")
483-
.WithBody(String.Format(
484-
"<a id='link' href='{0}'>Click here to navigate to another page.</a>", blank)));
485-
486-
SetSimpleOnBeforeUnload("onbeforeunload message");
487-
488-
driver.FindElement(By.Id("link")).Click();
489-
WaitFor(() => driver.Title == "Success", "Title was not 'Success'");
490-
}
491-
492-
[Test]
493-
[IgnoreBrowser(Browser.IE, "Test as written does not trigger alert; also onbeforeunload alert on close will hang browser")]
494-
[IgnoreBrowser(Browser.Chrome, "Test as written does not trigger alert")]
495-
[IgnoreBrowser(Browser.Edge, "Test as written does not trigger alert")]
496-
[IgnoreBrowser(Browser.Firefox, "After version 27, Firefox does not trigger alerts on unload.")]
497-
[IgnoreBrowser(Browser.Safari, "Safari does not trigger alerts on unload.")]
498-
public void ShouldHandleAlertOnWindowClose()
499-
{
500-
string pageWithOnBeforeUnload = EnvironmentManager.Instance.UrlBuilder.CreateInlinePage(new InlinePage()
501-
.WithOnBeforeUnload("javascript:alert(\"onbeforeunload\")")
502-
.WithBody("<p>Page with onbeforeunload event handler</p>"));
503-
driver.Url = EnvironmentManager.Instance.UrlBuilder.CreateInlinePage(new InlinePage()
504-
.WithBody(string.Format(
505-
"<a id='open-new-window' href='{0}' target='newwindow'>open new window</a>", pageWithOnBeforeUnload)));
506-
507-
string mainWindow = driver.CurrentWindowHandle;
508-
try
509-
{
510-
driver.FindElement(By.Id("open-new-window")).Click();
511-
WaitFor(WindowHandleCountToBe(2), "Window count was not 2");
512-
WaitFor(WindowWithName("newwindow"), "Could not find window with name 'newwindow'");
513-
driver.Close();
514-
515-
IAlert alert = WaitFor<IAlert>(AlertToBePresent, "No alert found");
516-
string value = alert.Text;
517-
alert.Accept();
518-
519-
Assert.AreEqual("onbeforeunload", value);
520-
521-
}
522-
finally
523-
{
524-
driver.SwitchTo().Window(mainWindow);
525-
WaitFor(ElementTextToEqual(driver.FindElement(By.Id("open-new-window")), "open new window"), "Could not find element with text equal to 'open new window'");
526-
}
527-
}
528-
529417
[Test]
530418
[IgnoreBrowser(Browser.Firefox, "Driver chooses not to return text from unhandled alert")]
531419
public void IncludesAlertTextInUnhandledAlertException()
@@ -566,51 +454,14 @@ public void ShouldHandleAlertOnFormSubmit()
566454

567455
IWebElement element = driver.FindElement(By.Id("theForm"));
568456
element.Submit();
569-
IAlert alert = driver.SwitchTo().Alert();
457+
IAlert alert = WaitFor<IAlert>(AlertToBePresent, "No alert found");
570458
string text = alert.Text;
571459
alert.Accept();
572460

573461
Assert.AreEqual("Tasty cheese", text);
574462
Assert.AreEqual("Testing Alerts", driver.Title);
575463
}
576464

577-
//------------------------------------------------------------------
578-
// Tests below here are not included in the Java test suite
579-
//------------------------------------------------------------------
580-
[Test]
581-
[IgnoreBrowser(Browser.Safari, "Safari does not display onBeforeUnload dialogs")]
582-
public void ShouldHandleAlertOnPageBeforeUnload()
583-
{
584-
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("pageWithOnBeforeUnloadMessage.html");
585-
IWebElement element = driver.FindElement(By.Id("navigate"));
586-
element.Click();
587-
IAlert alert = WaitFor<IAlert>(AlertToBePresent, "No alert found");
588-
alert.Dismiss();
589-
Assert.That(driver.Url, Does.Contain("pageWithOnBeforeUnloadMessage.html"));
590-
591-
// Can't move forward or even quit the driver
592-
// until the alert is accepted.
593-
element.Click();
594-
alert = WaitFor<IAlert>(AlertToBePresent, "No alert found");
595-
alert.Accept();
596-
WaitFor(() => { return driver.Url.Contains(alertsPage); }, "Browser URL does not contain " + alertsPage);
597-
Assert.That(driver.Url, Does.Contain(alertsPage));
598-
}
599-
600-
[Test]
601-
[NeedsFreshDriver(IsCreatedAfterTest = true)]
602-
[IgnoreBrowser(Browser.Safari, "Safari does not display onBeforeUnload dialogs")]
603-
public void ShouldHandleAlertOnPageBeforeUnloadAlertAtQuit()
604-
{
605-
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("pageWithOnBeforeUnloadMessage.html");
606-
IWebElement element = driver.FindElement(By.Id("navigate"));
607-
element.Click();
608-
IAlert alert = WaitFor<IAlert>(AlertToBePresent, "No alert found");
609-
610-
// CloserCurrentDriver() contains a call to driver.Quit()
611-
EnvironmentManager.Instance.CloseCurrentDriver();
612-
}
613-
614465
// Disabling test for all browsers. Authentication API is not supported by any driver yet.
615466
// [Test]
616467
[IgnoreBrowser(Browser.Chrome)]

‎dotnet/test/common/ClickScrollingTest.cs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ public void ClickingOnAnchorScrollsPage()
2323

2424
driver.FindElement(By.PartialLinkText("last speech")).Click();
2525

26-
long yOffset = (long)((IJavaScriptExecutor)driver).ExecuteScript(scrollScript);
26+
// Sometimes JS is returning a double
27+
object result = ((IJavaScriptExecutor)driver).ExecuteScript(scrollScript);
28+
var yOffset = Convert.ChangeType(result, typeof(long));
2729

2830
//Focusing on to click, but not actually following,
2931
//the link will scroll it in to view, which is a few pixels further than 0
@@ -52,6 +54,7 @@ public void ShouldBeAbleToClickOnAnElementHiddenByOverflow()
5254
}
5355

5456
[Test]
57+
[IgnoreBrowser(Browser.Firefox, "https://github.com/mozilla/geckodriver/issues/2013")]
5558
public void ShouldBeAbleToClickOnAnElementHiddenByDoubleOverflow()
5659
{
5760
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/page_with_double_overflow_auto.html");
@@ -70,6 +73,7 @@ public void ShouldBeAbleToClickOnAnElementHiddenByYOverflow()
7073
}
7174

7275
[Test]
76+
[IgnoreBrowser(Browser.Firefox, "https://github.com/mozilla/geckodriver/issues/2013")]
7377
public void ShouldBeAbleToClickOnAnElementPartiallyHiddenByOverflow()
7478
{
7579
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/page_with_partially_hidden_element.html");
@@ -90,6 +94,7 @@ public void ShouldNotScrollOverflowElementsWhichAreVisible()
9094

9195

9296
[Test]
97+
[IgnoreBrowser(Browser.Firefox, "https://github.com/mozilla/geckodriver/issues/2013")]
9398
public void ShouldNotScrollIfAlreadyScrolledAndElementIsInView()
9499
{
95100
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scroll3.html");
@@ -117,6 +122,7 @@ public void ShouldScrollOverflowElementsIfClickPointIsOutOfViewButElementIsInVie
117122
}
118123

119124
[Test]
125+
[IgnoreBrowser(Browser.Firefox, "https://bugzilla.mozilla.org/show_bug.cgi?id=1314462")]
120126
public void ShouldBeAbleToClickElementInAFrameThatIsOutOfView()
121127
{
122128
try
@@ -150,23 +156,6 @@ public void ShouldBeAbleToClickElementThatIsOutOfViewInAFrame()
150156
}
151157
}
152158

153-
[Test]
154-
[Ignore("All tested browses scroll non-scrollable frames")]
155-
public void ShouldNotBeAbleToClickElementThatIsOutOfViewInANonScrollableFrame()
156-
{
157-
try
158-
{
159-
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/page_with_non_scrolling_frame.html");
160-
driver.SwitchTo().Frame("scrolling_frame");
161-
IWebElement element = driver.FindElement(By.Name("scroll_checkbox"));
162-
Assert.That(() => element.Click(), Throws.InstanceOf<WebDriverException>());
163-
}
164-
finally
165-
{
166-
driver.SwitchTo().DefaultContent();
167-
}
168-
}
169-
170159
[Test]
171160
public void ShouldBeAbleToClickElementThatIsOutOfViewInAFrameThatIsOutOfView()
172161
{
@@ -185,6 +174,7 @@ public void ShouldBeAbleToClickElementThatIsOutOfViewInAFrameThatIsOutOfView()
185174
}
186175

187176
[Test]
177+
[IgnoreBrowser(Browser.Firefox, "https://github.com/mozilla/geckodriver/issues/2013")]
188178
public void ShouldBeAbleToClickElementThatIsOutOfViewInANestedFrame()
189179
{
190180
try
@@ -203,6 +193,7 @@ public void ShouldBeAbleToClickElementThatIsOutOfViewInANestedFrame()
203193
}
204194

205195
[Test]
196+
[IgnoreBrowser(Browser.Firefox, "https://github.com/mozilla/geckodriver/issues/2013")]
206197
public void ShouldBeAbleToClickElementThatIsOutOfViewInANestedFrameThatIsOutOfView()
207198
{
208199
try
@@ -230,6 +221,7 @@ public void ShouldNotScrollWhenGettingElementSize()
230221
}
231222

232223
[Test]
224+
[IgnoreBrowser(Browser.Firefox, "https://bugzilla.mozilla.org/show_bug.cgi?id=1314462")]
233225
public void ShouldBeAbleToClickElementInATallFrame()
234226
{
235227
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/page_with_tall_frame.html");

‎dotnet/test/common/ClickTest.cs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,6 @@ public void ShouldOnlyFollowHrefOnce()
141141
Assert.AreEqual(windowHandlesBefore + 1, driver.WindowHandles.Count);
142142
}
143143

144-
[Test]
145-
[Ignore("Ignored for all browsers")]
146-
public void ShouldSetRelatedTargetForMouseOut()
147-
{
148-
Assert.Fail("Must. Write. Meamingful. Test (but we don't fire mouse outs synthetically");
149-
}
150-
151144
[Test]
152145
public void ClickingLabelShouldSetCheckbox()
153146
{
@@ -183,6 +176,7 @@ public void CanClickOnALinkThatContainsTextWrappedInASpan()
183176
}
184177

185178
[Test]
179+
[IgnoreBrowser(Browser.Firefox, "https://github.com/mozilla/geckodriver/issues/653")]
186180
public void CanClickOnALinkThatContainsEmbeddedBlockElements()
187181
{
188182
driver.FindElement(By.Id("embeddedBlock")).Click();
@@ -198,7 +192,6 @@ public void CanClickOnAnElementEnclosedInALink()
198192
Assert.AreEqual("XHTML Test Page", driver.Title);
199193
}
200194

201-
// See http://code.google.com/p/selenium/issues/attachmentText?id=2700
202195
[Test]
203196
public void ShouldBeAbleToClickOnAnElementInTheViewport()
204197
{
@@ -218,6 +211,7 @@ public void ClicksASurroundingStrongTag()
218211
}
219212

220213
[Test]
214+
[IgnoreBrowser(Browser.Firefox, "https://bugzilla.mozilla.org/show_bug.cgi?id=1502636")]
221215
public void CanClickAnImageMapArea()
222216
{
223217
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("click_tests/google_map.html");
@@ -234,6 +228,7 @@ public void CanClickAnImageMapArea()
234228
}
235229

236230
[Test]
231+
[IgnoreBrowser(Browser.Firefox, "https://bugzilla.mozilla.org/show_bug.cgi?id=1422272")]
237232
public void ShouldBeAbleToClickOnAnElementGreaterThanTwoViewports()
238233
{
239234
string url = EnvironmentManager.Instance.UrlBuilder.WhereIs("click_too_big.html");
@@ -331,22 +326,6 @@ public void ShouldBeAbleToClickOnASpanThatWrapsToTheNextLine()
331326
Assert.AreEqual("Submitted Successfully!", driver.Title);
332327
}
333328

334-
[Test]
335-
[IgnoreBrowser(Browser.IE, "Element is properly seen as obscured.")]
336-
[IgnoreBrowser(Browser.Chrome, "Element is properly seen as obscured.")]
337-
[IgnoreBrowser(Browser.Edge, "Element is properly seen as obscured.")]
338-
[IgnoreBrowser(Browser.Firefox, "Element is properly seen as obscured.")]
339-
[IgnoreBrowser(Browser.Safari, "Element is properly seen as obscured.")]
340-
public void ShouldBeAbleToClickOnAPartiallyOverlappedLinkThatWrapsToTheNextLine()
341-
{
342-
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("click_tests/wrapped_overlapping_elements.html");
343-
344-
driver.FindElement(By.Id("link")).Click();
345-
346-
WaitFor(() => driver.Title == "Submitted Successfully!", "Expected title to be 'Submitted Successfully!'");
347-
Assert.AreEqual("Submitted Successfully!", driver.Title);
348-
}
349-
350329
[Test]
351330
public void ClickingOnADisabledElementIsANoOp()
352331
{

0 commit comments

Comments
 (0)