use of org.openqa.selenium.Alert in project java-client by appium.
the class WebDriverEventListenerCompatibilityTest method alertEventTest.
@Test
public void alertEventTest() {
try {
Alert alert = driver.switchTo().alert();
alert.accept();
alert.dismiss();
alert.sendKeys("Keys");
assertThat(listener.messages, hasItems(WEBDRIVER_EVENT_LISTENER + "Attempt to accept alert", WEBDRIVER_EVENT_LISTENER + "The alert was accepted", WEBDRIVER_EVENT_LISTENER + "Attempt to dismiss alert", WEBDRIVER_EVENT_LISTENER + "The alert was dismissed"));
assertThat(listener.messages.size(), is(4));
} finally {
listener.messages.clear();
}
}
use of org.openqa.selenium.Alert in project opentest by mcdcorp.
the class HandleModal method run.
@Override
public void run() {
super.run();
String perform = this.readStringArgument("perform");
this.waitForAsyncCallsToFinish();
WebDriverWait wait = new WebDriverWait(this.driver, this.explicitWaitSec);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
String text;
switch(perform.toLowerCase()) {
case "accept":
alert.accept();
break;
case "dismiss":
alert.dismiss();
break;
case "gettext":
text = alert.getText();
this.writeOutput("text", text);
break;
case "sendkeys":
text = this.readStringArgument("text", null);
String key = this.readStringArgument("key", null);
if (text != null) {
alert.sendKeys(text);
} else if (key != null) {
String keyString = Keys.valueOf(key.toUpperCase()).toString();
alert.sendKeys(keyString);
} else {
throw new RuntimeException("Neither the \"text\" argument, nor the \"key\" argument were provided.");
}
break;
default:
throw new RuntimeException("The \"perform\" argument must have one of the following values: accept, " + "authenticate, dismiss, getText, sendKeys, setCredentials.");
}
}
use of org.openqa.selenium.Alert in project devonfw-testing by devonfw.
the class ContextMenuPage method isAlertTextValid.
public boolean isAlertTextValid() {
WebDriverWait wait = new WebDriverWait(BasePage.getDriver(), timeoutInSec);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = BasePage.getDriver().switchTo().alert();
return alert.getText().equals(expectedAlertText);
}
use of org.openqa.selenium.Alert in project elastest-instrumentation-manager by elastest.
the class EimPluginBaseTest method deletePipelineJob.
protected void deletePipelineJob(WebDriver driver, String jobName) {
navigateTo(driver, jenkinsCIUrl);
if (isJobCreated(jobName)) {
log.info("Deleting Job created for the test");
log.info("Go inside Pipeline Job");
getElementByXpath(driver, "//*[@id=\"job_PJob_1\"]/td[3]/a", 30, false).click();
log.info("Click delete Pipeline Job");
driver.findElement(By.linkText("Delete Pipeline")).click();
log.info("Confirm delete Pipeline Job");
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.accept();
}
}
use of org.openqa.selenium.Alert in project acceptance-test-harness by jenkinsci.
the class CapybaraPortingLayerImpl method runThenHandleAlert.
public void runThenHandleAlert(Runnable runnable, Consumer<Alert> action, int timeoutSeconds) {
String oldWindow = driver.getWindowHandle();
if (runnable != null) {
runnable.run();
}
Wait<WebDriver> wait = new Wait<>(driver, time).pollingEvery(500, TimeUnit.MILLISECONDS).withTimeout(timeoutSeconds, TimeUnit.SECONDS);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
try {
action.accept(alert);
} finally {
driver.switchTo().window(oldWindow);
}
}
Aggregations