Closing alert that can remain after previous test
import static org.openqa.selenium.testing.TestUtilities.getFirefoxVersion;
import static org.openqa.selenium.testing.TestUtilities.isFirefox;
+import org.junit.After;
import org.junit.Test;
import org.openqa.selenium.environment.webserver.Page;
import org.openqa.selenium.support.ui.ExpectedCondition;
@Ignore(SAFARI)
public class AlertsTest extends JUnit4TestBase {
+ @After
+ public void closeAlertIfPresent() {
+ try {
+ driver.switchTo().alert().dismiss();
+ } catch (WebDriverException ignore) {
+ }
+ }
+
private String alertPage(String alertText) {
return appServer.create(new Page()
.withTitle("Testing Alerts")
