Skip to content

Commit

Permalink
Updating .NET Alerts tests.
Browse files Browse the repository at this point in the history
Making test more robust by waiting for proper condition and adding test
for quitting browser with onBeforeUnload event handler in place.
  • Loading branch information
jimevans committed Apr 17, 2013
1 parent a6861f9 commit 2f6e67d
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion dotnet/test/WebDriver.Common.Tests/AlertsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ public void SwitchingToMissingAlertInAClosedWindowThrows()
{
driver.FindElement(By.Id("open-new-window")).Click();
WaitFor(WindowHandleCountToBe(2));
driver.SwitchTo().Window("newwindow").Close();
WaitFor(WindowWithName("newwindow"));
driver.Close();
WaitFor(WindowHandleCountToBe(1));

try
Expand Down Expand Up @@ -629,6 +630,29 @@ public void ShouldHandleOnBeforeUnloadAlert()
Assert.IsTrue(driver.Url.Contains(alertsPage));
}

[Test]
[IgnoreBrowser(Browser.PhantomJS, "Alert commands not yet implemented in GhostDriver")]
[IgnoreBrowser(Browser.Safari)]
[NeedsFreshDriver(AfterTest = true)]
public void ShouldHandleOnBeforeUnloadAlertAtClose()
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("pageWithOnBeforeUnloadMessage.html");
IWebElement element = driver.FindElement(By.Id("navigate"));
element.Click();
IAlert alert = WaitFor<IAlert>(AlertToBePresent);
driver.Quit();
//alert.Dismiss();
//Assert.IsTrue(driver.Url.Contains("pageWithOnBeforeUnloadMessage.html"));

//// Can't move forward or even quit the driver
//// until the alert is accepted.
//element.Click();
//alert = WaitFor<IAlert>(AlertToBePresent);
//alert.Accept();
//WaitFor(() => { return driver.Url.Contains(alertsPage); });
//Assert.IsTrue(driver.Url.Contains(alertsPage));
}

[Test]
[IgnoreBrowser(Browser.PhantomJS, "Alert commands not yet implemented in GhostDriver")]
[IgnoreBrowser(Browser.Safari)]
Expand Down

0 comments on commit 2f6e67d

Please sign in to comment.