Created
August 20, 2020 10:19
-
-
Save angelovstanton/80a45af23f401a7adc4006acafecfa6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void handleJavaScripPopUps() { | |
driver.navigate().to("http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm"); | |
driver.switchTo().frame("iframeResult"); | |
var button = driver.findElement(By.xpath("/html/body/button")); | |
button.click(); | |
Alert alert = driver.switchTo().alert(); | |
if (alert.getText().equals("Press a button!")) { | |
alert.accept(); | |
} | |
else { | |
alert.dismiss(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment