Skip to content

Commit

Permalink
Adding new tests for alerts. Actually copying tests from .Net to Java
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Oct 19, 2013
1 parent c67023e commit 5b9adac
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dotnet/test/common/AlertsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,6 @@ public void CanQuitWhenAnAlertIsPresent()
EnvironmentManager.Instance.CloseCurrentDriver();
}

//------------------------------------------------------------------
// Tests below here are not included in the Java test suite
//------------------------------------------------------------------
[Test]
[IgnoreBrowser(Browser.PhantomJS, "Alert commands not yet implemented in GhostDriver")]
[IgnoreBrowser(Browser.Safari)]
Expand Down Expand Up @@ -644,6 +641,9 @@ public void ShouldHandleOnBeforeUnloadAlertAtClose()
driver = null;
}

//------------------------------------------------------------------
// Tests below here are not included in the Java test suite
//------------------------------------------------------------------
[Test]
[IgnoreBrowser(Browser.PhantomJS, "Alert commands not yet implemented in GhostDriver")]
[IgnoreBrowser(Browser.Safari)]
Expand Down
31 changes: 31 additions & 0 deletions java/client/test/org/openqa/selenium/AlertsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,37 @@ public void testShouldHandleAlertOnPageUnload() {
waitFor(elementTextToEqual(driver, By.id("open-page-with-onunload-alert"), "open new page"));
}

@JavascriptEnabled
@Test
public void testShouldHandleAlertOnPageBeforeUnload() {
driver.get(appServer.whereIs("pageWithOnBeforeUnloadMessage.html"));

WebElement element = driver.findElement(By.id("navigate"));
element.click();

Alert alert = waitFor(alertToBePresent(driver));
alert.dismiss();
assertThat(driver.getCurrentUrl(), containsString("pageWithOnBeforeUnloadMessage.html"));

element.click();
alert = waitFor(alertToBePresent(driver));
alert.accept();
assertEquals("Testing Alerts", driver.getTitle());
}

@NoDriverAfterTest
@Test
public void testShouldHandleAlertOnPageBeforeUnloadAtQuit() {
driver.get(appServer.whereIs("pageWithOnBeforeUnloadMessage.html"));

WebElement element = driver.findElement(By.id("navigate"));
element.click();

waitFor(alertToBePresent(driver));

driver.quit();
}

@JavascriptEnabled
@Ignore(value = {ANDROID, CHROME}, reason = "On Android, alerts do not pop up" +
" when a window is closed.")
Expand Down

0 comments on commit 5b9adac

Please sign in to comment.