By using Alert interface we can handle web based popup. It has different methods like accept(), dismiss() etc. So first we need to switch on alert popup then perform any action.
driver.switchTo().alert().aceept(); // To click on OK button on alert.
driver.switchTo().alert().dismiss(); // To click on cancel button on alert
String alerttext=driver.switchTo().alert().getText();
driver.switchTo().alert().aceept(); // To click on OK button on alert.
driver.switchTo().alert().dismiss(); // To click on cancel button on alert
String alerttext=driver.switchTo().alert().getText();
No comments:
Post a Comment