How to work with JavaScript Alert in Selenium WebDriver

In this article we are going to see the functions needed to control JavaScript pop-up alert messages. I am using c#(CV2010).

After declaring web driver declare the Alart type veritable.
IAlert myAlert;
In the function , initiate myAlert object as
myAlart = driver.SwitchTo().Alert();
Now, this myAlart object can do some work.
-To  Accept the alert
-To Dismiss the alert
-To Write text in the alert(when needed)
-To get the text of the alert
Note : This will provide a string text as output

...Thanks...:)... To be continued...

No comments:

Post a Comment