Package org.openqa.selenium

Examples of org.openqa.selenium.Alert


      error("Exception encounterd while running async javascript - '" + script +"'");
    }
  }
 
  public void javascript_popup_click_ok() {
    Alert alert = get_current_alert_box();
    if(alert != null) {
      action("Accepted the javascript popup '" + alert.getText() + "'");
      alert.accept();
    }
  }
View Full Code Here


  public void javascript_popup_dismiss() {
    if(browser.is_Chrome()) {
      javascript_popup_click_ok();
      return;
    }
    Alert alert = get_current_alert_box();
    if(alert != null) {
      action("Dismissed the javascript popup '" + alert.getText() + "'");
      alert.dismiss();
    }
  }
View Full Code Here

    try {
      el.getAttribute("name");
      Assert.fail("cannot interact while action sheet is opened");
    } catch (UnhandledAlertException e) {
    }
    Alert alert = driver.switchTo().alert();
    alert.dismiss();
  }
View Full Code Here

  public void okCancel() throws Exception {
    By b = By.xpath(actionOKCancel);
    WebElement el = driver.findElement(b);
    el.click();

    Alert alert = driver.switchTo().alert();
    alert.dismiss();
    try {
      driver.switchTo().alert();
      Assert.fail();
    } catch (NoAlertPresentException e) {
      // ignore
View Full Code Here

  public void findWhenAlertAreGone() throws Exception {
    By b = By.xpath(actionOKCancel);
    WebElement el = driver.findElement(b);
    el.click();

    Alert alert = driver.switchTo().alert();
    try {
      el.click();
      Assert.fail();
    } catch (UnhandledAlertException e) {
      //expected
    }
    alert.accept();
    el.click();
    driver.switchTo().alert();
    alert.accept();
  }
View Full Code Here

  }

  private Alert waitForAlert(WebDriver driver) {
    long timeoutInMs = 2000;
    long deadline = System.currentTimeMillis() + timeoutInMs;
    Alert res = null;
    while (res == null) {
      try {
        res = driver.switchTo().alert();
        return res;
      } catch (NoAlertPresentException e) {
View Full Code Here

  public void alertGetText() throws Exception {
    By b = By.xpath(alertOK);
    WebElement el = driver.findElement(b);
    el.click();

    Alert alert = waitForAlert(driver);
    Assert.assertEquals(alert.getText(), "<Alert message>");
    alert.dismiss();
    waitForAlertToBeGone();
  }
View Full Code Here

      Assert.fail("should have thrown");
    } catch (NoAlertPresentException e) {
      // expected
    }
    el.click();
    Alert alert = d.switchTo().alert();
    alert.sendKeys("test");
    alert.accept();
  }
View Full Code Here

    RemoteWebDriver d = (RemoteWebDriver) driver;
    By b = By.xpath(alertLocator);
    WebElement el = driver.findElement(b);
    el.click();

    Alert alert = waitForAlert(driver);
    alert.dismiss();

    try {
      d.switchTo().alert();
      Assert.fail("alert should be gone.");
    } catch (NoAlertPresentException e) {
View Full Code Here

    RemoteWebDriver d = (RemoteWebDriver) driver;
    By b = By.xpath(alertLocator);
    WebElement el = driver.findElement(b);
    el.click();

    Alert alert = waitForAlert(driver);
    alert.accept();

    try {
      d.switchTo().alert();
      Assert.fail("alert should be gone.");
    } catch (NoAlertPresentException e) {
View Full Code Here

TOP

Related Classes of org.openqa.selenium.Alert

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.