In this quick Selenium tutorial, you will learn how to handle JavaScript alerts using Selenium WebDriver in Java.
We cover:
• How to detect alert type
• How to switch focus using switchTo().alert()
• How to use accept()
• How to use dismiss()
• How to use sendKeys() for prompt alerts
Code used in this video:
Alert alert = driver.switchTo().alert();
alert.accept();
alert.dismiss();
alert.sendKeys("string");
If you’re preparing for an SDET interview or learning Selenium automation, this is a must-know concept.
Subscribe for more short and powerful SDET tutorials every week.
#Selenium #SDET #AutomationTesting #Java #SoftwareTesting #QA