how do I handle modal dialogs with selenium 2

13,957

Solution 1

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();

    }

Solution 2

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).

Solution 3

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

Share:
13,957

Related videos on Youtube

Aidan_Mc_Donnell
Author by

Aidan_Mc_Donnell

Updated on June 04, 2022

Comments

  • Aidan_Mc_Donnell
    Aidan_Mc_Donnell about 16 hours

    I have a link that opens a modal dialog

    How can Selenium 2 handle this.

    Thanks

    Aidan