alerts pop ups in selenium
1- HTML Alerts: HTML Alerts are inside of the HTML.
Therefore, we can locate using one of eight locators of Selenium.
And do any action need, such as click & close
2- JavaScript Alerts: There are 3 types of JS alerts.
1- Warning/Information: You only have 1 option. You have to accept.
2- Confirmation: You can both accept or dismiss.
3- Prompt: You can accept, dismiss, AND send keys.
Alert alert = driver.switchTo().alert();
alert.accept(); clicks on the “Ok” button as soon as
the pop-up window appears.
alert.dismiss(); clicks on the “Cancel” button
as soon as the pop-up window appears.
alert.sendKeys(); enters the specified string pattern into the alert box.
alert.getText(); returns the text displayed on the alert box