Browser Count not increasing when modal html dialog is opened

4 posts, 0 answers
  1. Koti Reddy
    Koti Reddy avatar
    6 posts
    Member since:
    Oct 2010

    Posted 29 May 2012 Link to this post

    Hii,
    I am not able to get the handle of new modal window ,which i am opening by
    clicking some button. Window gets opened but browser count is not increasing.
    Its working for non modal html windows .ANY HELP
    ?????
  2. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 29 May 2012 Link to this post

    Hello Koti,

    Modal Popups require special code and should be handled as demonstrated here.

    Here is additional sample code I wrote against a public site with a Modal Popup:

    Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
     
    Manager.SetNewBrowserTracking(true);
    Log.WriteLine("Browser Count: " + Manager.Browsers.Count.ToString());
     
    Find.ByContent<HtmlAnchor>("this link").ScrollToVisible();
    Find.ByContent<HtmlAnchor>("this link").MouseClick();
     
    if (ActiveBrowser.BrowserType == BrowserType.InternetExplorer)
    {
        ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions ieActions = ((ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions)(ActiveBrowser.Actions));
        ieActions.ConnectIEDialog("A Modal Pop-Up -- Webpage Dialog", 5000);
     
        Manager.WaitForNewBrowserConnect("simple.html", true, 5000);
        Assert.IsTrue(ActiveBrowser.IsIEDialog);
        //Manager.ActiveBrowser.WaitUntilReady();
     
        Log.WriteLine("Browser Count: " + Manager.Browsers.Count.ToString());
        ActiveBrowser.Close();
    }
    Assert.IsFalse(ActiveBrowser.IsIEDialog);
     
    Log.WriteLine("Browser Count: " + Manager.Browsers.Count.ToString());

    It writes the following to the test log:

    [Trace] : Browser Count: 1
    [Trace] : Browser Count: 2
    [Trace] : Browser Count: 1


    Regards,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Koti Reddy
    Koti Reddy avatar
    6 posts
    Member since:
    Oct 2010

    Posted 29 May 2012 Link to this post

    Thanks Anthony.

    Is the code specific to IE? Is it extensible to other browsers as well (Chrome and FF)?

    We have these HTML dialogs that are opened via "window.showmodaldialog()". These dialogs show the modal property in IE but fail to do so in Chrome.

    However, as I mentioned, attempting to get them as ActiveBrowser does not work.
  4. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 30 May 2012 Link to this post

    Hello Koti,

    Modal Popups simply require extra code for IE execution. Here's an adapted sample that works in Chrome (and would work in FF as well if FF rendered a URL in the popup):

    Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
    Manager.LaunchNewBrowser(BrowserType.Chrome);
     
    Manager.SetNewBrowserTracking(true);
    Log.WriteLine("Browser Count: " + Manager.Browsers.Count.ToString());
     
    Find.ByContent<HtmlAnchor>("this link").ScrollToVisible();
    Find.ByContent<HtmlAnchor>("this link").MouseClick();
     
    if (ActiveBrowser.BrowserType == BrowserType.InternetExplorer)
    {
        ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions ieActions = ((ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions)(ActiveBrowser.Actions));
        ieActions.ConnectIEDialog("A Modal Pop-Up -- Webpage Dialog", 5000);
    }
     
    Manager.WaitForNewBrowserConnect("simple.html", true, 5000);
    System.Threading.Thread.Sleep(1000);
    Assert.IsTrue(ActiveBrowser.ContainsText("This is in a modal dialogue"));
     
    Log.WriteLine("Browser Count: " + Manager.Browsers.Count.ToString());
    ActiveBrowser.Close();
    Log.WriteLine("Browser Count: " + Manager.Browsers.Count.ToString());


    All the best,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top