This is a migrated thread and some comments may be shown as answers.
Browser Count not increasing when modal html dialog is opened
3 Answers 30 Views
This is a migrated thread and some comments may be shown as answers.
Koti Reddy
Top achievements
Rank 1
Koti Reddy asked on 29 May 2012, 01:18 PM
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
?????

3 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 29 May 2012, 03:49 PM
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
0
Koti Reddy
Top achievements
Rank 1
answered on 30 May 2012, 04:08 AM
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.
0
Anthony
Telerik team
answered on 30 May 2012, 04:01 PM
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
Asked by
Koti Reddy
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Koti Reddy
Top achievements
Rank 1
Share this question
or