how do I handle modal dialogs with selenium 2
-
27-09-2019 - |
Question
I have a link that opens a modal dialog
How can Selenium 2 handle this.
Thanks
Aidan
Solution
With selenium 2 , I'm able to select elements in a jquery modal dialog using the normal "findElement" method.
e.g. the following code in c#
[Test]
public void DialogBox()
{
var driver = new FirefoxDriver();
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 20));
driver.Navigate().GoToUrl("http://example.nemikor.com/basic-usage-of-the-jquery-ui-dialog/");
// open modal dialog
driver.FindElement(By.Id("opener")).Click();
// click a button on the modal dialog.
driver.FindElementByClassName("ui-icon ui-icon-closethick").Click();
}
OTHER TIPS
This feature to handle modal dialog is not shipped yet into webdriver until the last release 2.0b3 (link).
Eagerly waiting for the next version to become public soon.(Test Environment: C#, Webdriver 2.0b3 and Nunit
).
I think there are some known issues on this http://code.google.com/p/selenium/issues/detail?id=284 but a possible solution given at this link
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow