how to dismiss a alert box by clicking "OK" button? I saw on WebDriver Google group that Simon is adding this feature. I am not sure whether this is supported or not.
An alert can be of three types – a prompt which allows the user to input text, a normal alert and a confirmation alert. By default, the webdriver can only access the main page, once an alert comes up, the method switchTo(). alert() is used to shift the focus webdriver control to the alert.
WebDriver can get the text from the popup and accept or dismiss these alerts.
New Selenium IDE We can check if an alert exists with Selenium webdriver. An alert is created with the help of Javascript. We shall use the explicit wait concept in synchronization to verify the presence of an alert.
C# code:
IAlert alert = driver.SwitchTo().Alert();
alert.Accept();
System.Threading.Thread.Sleep(milliseconds);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With