Skip to content

Instantly share code, notes, and snippets.

Created March 1, 2021 06:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
public void alerts() {
driver.findElement(By.xPath("//*[contains(normalize-space(text()), 'Click for JS Alert')]")).click();
driver.findElement(By.xPath("//*[contains(normalize-space(text()), 'Click for JS Prompt')]")).click();
Alert inputAlert = driver.switchTo().alert();
String text = inputAlert.getText();
inputAlert.sendKeys("Look Mom! I can automate alerts :) ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment