Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebDriver dismiss an Alert box

Tags:

webdriver

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.

like image 865
zihaoyu Avatar asked Aug 31 '10 22:08

zihaoyu


People also ask

What is Alert () in driver switchTo ()?

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.

Can we handle Javascript Alert in WebDriver?

WebDriver can get the text from the popup and accept or dismiss these alerts.

How check Alert is present or not in Selenium?

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.


1 Answers

C# code:

IAlert alert = driver.SwitchTo().Alert();
alert.Accept(); 
System.Threading.Thread.Sleep(milliseconds);
like image 125
MacGyver Avatar answered Oct 16 '22 06:10

MacGyver