Skip to content

Commit 397efe8

Browse files
committed
fixing UnexpectedAlertBehaviorTest
1 parent de2a217 commit 397efe8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

java/client/test/org/openqa/selenium/UnexpectedAlertBehaviorTest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,22 @@ private void runScenarioWithUnhandledAlert(UnexpectedAlertBehaviour behaviour,
116116
desiredCaps.setCapability(UNEXPECTED_ALERT_BEHAVIOUR, behaviour);
117117
}
118118
driver2 = new WebDriverBuilder().setDesiredCapabilities(desiredCaps).get();
119-
runScenarioWithUnhandledAlert(expectedAlertText);
119+
runScenarioWithUnhandledAlert(expectedAlertText, behaviour != UnexpectedAlertBehaviour.IGNORE);
120120
}
121121

122122
private void runScenarioWithUnhandledAlert(String expectedAlertText) {
123+
runScenarioWithUnhandledAlert(expectedAlertText, true);
124+
}
125+
126+
private void runScenarioWithUnhandledAlert(String expectedAlertText, Boolean ignoreUnhandledAlertException) {
123127
driver2.get(pages.alertsPage);
124128
driver2.findElement(By.id("prompt-with-default")).click();
125129

126-
new WebDriverWait(driver2, 30).ignoring(UnhandledAlertException.class).until(elementTextToEqual(By.id("text"), expectedAlertText));
130+
WebDriverWait wait = new WebDriverWait(driver2, 30);
131+
if (ignoreUnhandledAlertException) {
132+
wait.ignoring(UnhandledAlertException.class);
133+
}
134+
wait.until(elementTextToEqual(By.id("text"), expectedAlertText));
127135
}
128136

129137
}

0 commit comments

Comments
 (0)