I have a link that opens a modal dialog
How can Selenium 2 handle this.
Thanks
Aidan
Selenium uses the getWindowHandles () and getWindowHandle () methods to work with child windows. The getWindowHandles () method contains all the window handle ids of the opened windows. The window id handles are held in the form of Set data structure [containing data type as String].
Modals prevent access to the main pageWhile a modal dialog is active a user cannot interact with the main page and is restricted to only the information in the modal for making decisions. Modal tasks should be easy to complete with the limited information presented in the dialog itself.
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();
}
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