use of org.openqa.selenium.Alert in project acceptance-test-harness by jenkinsci.
the class CapybaraPortingLayerImpl method confirmAlert.
@Override
public void confirmAlert(int timeout) {
WebDriverWait wait = new WebDriverWait(driver, timeout);
Alert promptAlert = wait.until(ExpectedConditions.alertIsPresent());
promptAlert.accept();
}
use of org.openqa.selenium.Alert in project selenium_java by sergueik.
the class AngularAndWebDriverTest method find_by_angular_partialButtonText.
@Test(enabled = false)
public void find_by_angular_partialButtonText() {
driver.get("http://localhost:8080/#/form");
ngWebDriver.waitForAngularRequestsToFinish();
driver.findElement(ByAngular.partialButtonText("Ale")).click();
Alert alert = driver.switchTo().alert();
assertThat(alert.getText(), containsString("Hello"));
alert.accept();
}
use of org.openqa.selenium.Alert in project selenium_java by sergueik.
the class AngularAndWebDriverTest method find_by_angular_buttonText.
@Test(enabled = false)
public void find_by_angular_buttonText() {
driver.get("http://localhost:8080/#/form");
ngWebDriver.waitForAngularRequestsToFinish();
driver.findElement(ByAngular.buttonText("Open Alert")).click();
Alert alert = driver.switchTo().alert();
assertThat(alert.getText(), containsString("Hello"));
alert.accept();
}
use of org.openqa.selenium.Alert in project selenium_java by sergueik.
the class SeleniumEasyTest method alertConfirmTest.
@Test(enabled = true)
public void alertConfirmTest() {
// wrong selector
String buttonSelector = String.format("//*[@id='easycont']//div[@class='panel-heading'][contains(normalize-space(.), '%s')]/..//button", "Java Script Confirm Box");
try {
WebElement buttonElement = wait.until(new ExpectedCondition<WebElement>() {
Predicate<WebElement> textCheck = _element -> {
String _text = _element.getText();
System.err.println("in filter: Text = " + _text);
return (Boolean) (_text.contains("Click me!"));
};
@Override
public WebElement apply(WebDriver d) {
System.err.println("Locating " + buttonSelector);
Optional<WebElement> e = d.findElements(By.xpath(buttonSelector)).stream().filter(textCheck).findFirst();
return (e.isPresent()) ? e.get() : (WebElement) null;
}
});
System.err.println("Acting on: " + buttonElement.getAttribute("outerHTML"));
highlight(buttonElement);
flash(buttonElement);
buttonElement.click();
sleep(1000);
} catch (Exception e) {
System.err.println("Exception: " + e.toString());
verificationErrors.append("Exception: " + e.toString());
}
try {
// dismiss alert
driver.switchTo().alert().dismiss();
} catch (NoAlertPresentException ex) {
// Alert not present - ignore
} catch (WebDriverException ex) {
System.err.println("Alert was not handled : " + ex.getStackTrace().toString());
return;
}
assertThat(driver.findElement(By.id("confirm-demo")).getText(), is(equalTo("You pressed Cancel!")));
}
use of org.openqa.selenium.Alert in project selenium_java by sergueik.
the class AppTest method test13_1.
// NOTE: this test is hanging the jbrowserdriver
// after the test is run orphaned java processess require a taskkill
@Ignore
@Test
public void test13_1() {
// Arrange
driver.get("http://suvian.in/selenium/2.3frame.html");
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector(".container .row .intro-message iframe")));
// Act
WebElement buttonElement = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.cssSelector("h3 button"))));
assertThat(buttonElement, notNullValue());
buttonElement.click();
// Assert
try {
// confirm alert
Alert alert = driver.switchTo().alert();
String alert_text = alert.getText();
assertThat(alert_text, containsString("You clicked on Green"));
} catch (NoAlertPresentException e) {
// Alert not present - ignore
} catch (WebDriverException e) {
System.err.println("Alert was not handled : " + e.getStackTrace().toString());
return;
}
}
Aggregations