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 System.out.println(javascriptprompt.getText()); // Get text on alert box javascriptprompt.accept(); System.out.println(javascriptprompt.getText()); // Get text on alert box System.out.println(javascriptprompt.getText()); // Get text on alert box javascriptprompt.accept(); System.out.println(javascriptconfirm.getText()); // Get text on alert box javascriptconfirm.accept(); System.out.println(javascriptconfirm.getText()); // Get text on alert box javascriptconfirm.accept();
public String confirm(String expectedDialogText) { Alert alert = driver.switchTo().alert(); String actualDialogText = alert.getText(); alert.accept(); checkDialogText(driver, expectedDialogText, actualDialogText); return actualDialogText; }
public String dismiss(String expectedDialogText) { Alert alert = driver.switchTo().alert(); String actualDialogText = alert.getText(); alert.dismiss(); checkDialogText(driver, expectedDialogText, actualDialogText); return actualDialogText; }
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; }
try { Alert alert = webdriver.switchTo().alert(); log.severe(e + ": " + alert.getText()); alert.accept(); savePageSourceToFile(config, fileName, webdriver, false);
@Test public void getAlertTextTest() { driver.findElement(MobileBy.AccessibilityId(iOSAutomationText)).click(); waiting.until(alertIsPresent()); assertFalse(StringUtils.isBlank(driver.switchTo().alert().getText())); } }
try { click(myButton); } catch (UnhandledAlertException f) { try { Alert alert = driver.switchTo().alert(); String alertText = alert.getText(); System.out.println("Alert data: " + alertText); alert.accept(); } catch (NoAlertPresentException e) { e.printStackTrace(); } }
// WARNING! Untested code written from memory without // benefit of an IDE! May not be exactly correct! // Switch the driver context to the alert Alert alertDialog = driver.switchTo().alert(); // Get the alert text String alertText = alertDialog.getText(); // Click the OK button on the alert. alertDialog.accept();
Alert alert = driver.switchTo().alert(); String alertText = alert.getText(); if (alertText.equals("error...")) { // Do Something... // dismiss alert alert.dismiss(); }
driver.get("http://www.httpwatch.com/httpgallery/authentication/#showExample10"); // open URL driver.findElement(By.id("displayImage")).click(); Thread.sleep(2000); driver.switchTo().alert(); Alert promptAlert = driver.switchTo().alert(); String alertText = promptAlert .getText(); System.out.println("Alert text is " + alertText); promptAlert.dismiss();
WebDriverWait wait = new WebDriverWait(WD, 30); wait.until(ExpectedConditions.alertIsPresent()); Alert alert = WD.switchTo().alert(); String alertText = alert.getText(); System.out.println(alertText); 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;
WebDriverWait wait = new WebDriverWait(5, TimeUnit.Seconds); element.click(); // Wait for the dialog to show wait.until(ExpectedConditions.alertIsPresent()); // Switch the driver context to the alert Alert alertDialog = driver.switchTo().alert(); // Get the alert text String alertText = alertDialog.getText(); // Click the OK button on the alert. alertDialog.accept();
@Override public String answeredBy(Actor actor) { return BrowseTheWeb.as(actor).getAlert().getText(); } }
public void javascript_popup_click_ok() { Alert alert = get_current_alert_box(); if(alert != null) { action("Accepted the javascript popup '" + alert.getText() + "'"); alert.accept(); } }
private String closeAlert(boolean confirm) { Alert alert = driver.switchTo().alert(); String text = alert.getText(); if (!confirm) { alert.dismiss(); } else { alert.accept(); } return text; }
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(); } }
@Step("DismissAlert with message \"([^\"]*)\"") public void dismissAlertWithMessage(final String message) { // Get a handle to the open alert, prompt or confirmation final Alert alert = webDriverContext().getWebDriver().switchTo().alert(); // this will throw a org.openqa.selenium.NoAlertPresentException if no // alert is present Assert.assertThat(alert.getText(), is(message)); // And acknowledge the alert (equivalent to clicking "OK") alert.accept(); } }
public boolean isAlertPresent() { try { Alert alert = driver.switchTo().alert(); LOG.keywordAppender().appendArgument("Message", alert.getText()); return true; } catch (NoAlertPresentException ex) { LOG.info("Did not find any alerts."); return false; } }
@Override public String execute(Context context, String... args) { Alert alert = context.getWrappedDriver().switchTo().alert(); String result = alert.getText(); context.getNextNativeAlertActionListener().actionPerformed(alert); return result; } }