Refine search
System.out.println(javascriptAlert.getText()); // Get text on alert box javascriptAlert.accept(); javascriptprompt.sendKeys("This is Selenium Training"); System.out.println(javascriptprompt.getText()); // Get text on alert box javascriptprompt.accept(); System.out.println(javascriptprompt.getText()); // Get text on alert box javascriptprompt.accept(); System.out.println(javascriptprompt.getText()); // Get text on alert box javascriptprompt.dismiss(); System.out.println(javascriptprompt.getText()); // Get text on alert box javascriptprompt.accept(); javascriptconfirm.accept(); System.out.println(javascriptconfirm.getText()); // Get text on alert box javascriptconfirm.accept(); javascriptconfirm.dismiss(); javascriptconfirm = myTestDriver.switchTo().alert(); System.out.println(javascriptconfirm.getText()); // Get text on alert box javascriptconfirm.accept();
public String prompt(String expectedDialogText, String inputText) { Alert alert = driver.switchTo().alert(); String actualDialogText = alert.getText(); if (inputText != null) alert.sendKeys(inputText); alert.accept(); checkDialogText(driver, expectedDialogText, actualDialogText); return actualDialogText; }
@Override public void confirmAlert(int timeout) { WebDriverWait wait = new WebDriverWait(driver, timeout); Alert promptAlert = wait.until(ExpectedConditions.alertIsPresent()); promptAlert.accept(); }
WebDriver driver = new FirefoxDriver(); driver.get("https:www.google.com"); WebDriverWait wait = new WebDriverWait(driver, 5 ); try{ if(wait.until(ExpectedConditions.alertIsPresent())==null) { System.out.println("alert was not present"); }else{ Alert alert = driver.switchTo().alert(); alert.accept(); System.out.println("alert was present"); } }catch(Exception e){ System.out.println("ignored alret not present exception" +e.getMessage()); } }
writeToFile(webdriver.getPageSource(), pageSource); Alert alert = webdriver.switchTo().alert(); log.severe(e + ": " + alert.getText()); alert.accept(); savePageSourceToFile(config, fileName, webdriver, false);
/** * Adds a new user/group to this matrix. */ public MatrixRow addUser(String name) { this.name.resolve().findElement(by.parent()).findElement(by.button("Add user or group…")).click(); WebDriverWait wait = new WebDriverWait(driver, 10); Alert promptAlert = wait.until(ExpectedConditions.alertIsPresent()); promptAlert.sendKeys(name); promptAlert.accept(); return getUser(name); }
public void delete(WebDriver driver) { deleteButton.click(); WebDriverWait wait = new WebDriverWait(driver, 2); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); alert.accept(); } }
String alertText = ""; WebDriverWait wait = new WebDriverWait(driver, 5); // This will wait for a maximum of 5 seconds, everytime wait is used driver.findElement(By.xpath("//button[text() = \"Edit\"]")).click();//causes page to alert() something wait.until(ExpectedConditions.alertIsPresent()); // Before you try to switch to the so given alert, he needs to be present. Alert alert = driver.switchTo().alert(); alertText = alert.getText(); alert.accept(); return alertText;
public String cancelConfirmation() { Alert alert = getAlert(); String seenText = alert.getText(); alert.dismiss(); driver.switchTo().defaultContent(); return seenText; }
/** * Accepts alert modal. */ public void acceptAlert() { WebDriver drv = getDriver(); Wait<WebDriver> wait = new WebDriverWait(drv, EXPLICIT_TIMEOUT, RETRY_TIME); try { wait.until((Function<WebDriver, Object>) dr -> isAlertPresent()); drv.switchTo().alert().accept(); Messager.ALERT_ACCEPTED.info(""); } catch (Exception e) { Messager.ALERT_NOT_ACCEPTED.error(""); } }
/** * Cancels alert modal. */ public void cancelAlert() { WebDriver drv = getDriver(); Wait<WebDriver> wait = new WebDriverWait(drv, EXPLICIT_TIMEOUT, RETRY_TIME); try { wait.until((Function<WebDriver, Object>) dr -> isAlertPresent()); drv.switchTo().alert().dismiss(); Messager.ALERT_CANCELED.info(""); } catch (Exception e) { Messager.ALERT_NOT_CANCELED.error(""); } }
public void actualTest(AppiumDriver driver) throws URISyntaxException, IOException { WebDriverWait wait = new WebDriverWait(driver, 10); try { // get to the photo view wait.until(ExpectedConditions.presenceOfElementLocated(photos)).click(); // wait for and click the correct image using a reference image template By sunriseImage = MobileBy.image(getReferenceImageB64()); wait.until(ExpectedConditions.presenceOfElementLocated(sunriseImage)).click(); // verify that the resulting alert proves we clicked the right image wait.until(ExpectedConditions.alertIsPresent()); String alertText = driver.switchTo().alert().getText(); Assert.assertThat(alertText, Matchers.containsString("sunrise")); } finally { driver.quit(); } } }