This is a migrated thread and some comments may be shown as answers.

HtmlControl Click(bool isClosing) method not removing browser from Manager.Current.Browsers Collection

2 Answers 67 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jamie
Top achievements
Rank 2
Jamie asked on 19 Dec 2011, 04:38 PM
I would expect if I am clicking an InputSubmit control with IsClosing = True, that the browser window that is closed with the invoke of the InputSubmit.Click(True) would be removed from the Manager.Current.Browsers collection since it is no longer open.

I am trying to write a test that when I click the Close link, that the window actually closes.  This is because the application I am testing opens multiple windows, and if they do not all close properly the next time I run the tests this cause other issues with open windows.

What is the proper way to check to see if the brower pop up window was properly closed?

2 Answers, 1 is accepted

Sort by
0
Jamie
Top achievements
Rank 2
answered on 19 Dec 2011, 06:20 PM
I found a page on your website:  http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/write-tests-in-code/advanced-topics/handling-html-popups-and-dialogs/built-in-dialog-handlers/handling-html-popups.aspx

Which explains a little about the Browsers collection.  So I used this to set up an example to my issue, I have an concluded if you call the ActiveBrowser.Close() it will remove the popup from the Manager.Current.Browsers collection.  But if you are using an html control to close a popup and setting IsClosed = True it does not.  I think this is an issue with the Telerik framework.  I would expect if I am clicking a control which is causing the browser window to close the Browsers collection should be updated and remove the closed browser window.

I have noticed when I am using the HtmlControl.Click(IsClosed = True), the popup browser window closes, but in the Manager.Current.Browsers collection the Visible property is being set to false.

So using some code from my sample here is what I have determined, note this.Action is a custom class I created to find the control and click the button using the Telerik framework:

 

Manager.Current.ActiveBrowser.NavigateTo("http://api8406/jmwsample");

Manager.Current.ActiveBrowser.WaitUntilReady();

Manager.Current.ActiveBrowser.Window.Maximize();

this.Action.ClickButton("popuptest", false, false);
Manager.Current.WaitForNewBrowserConnect("popuptest", true, 3000);

Assert.IsTrue(this.manager.Browsers.Count == 2);  // This is true in this case, two browser windows are opened.

this.manager.ActiveBrowser.Close();

Assert.IsTrue(this.manager.Browsers.Count == 1);  // This is true, there is only one browser window opened now.

 

Manager.Current.ActiveBrowser.NavigateTo("http://api8406/jmwsample");

Manager.Current.ActiveBrowser.WaitUntilReady();

Manager.Current.ActiveBrowser.Window.Maximize();

this.Action.ClickButton("popuptest", false, false);
Manager.Current.WaitForNewBrowserConnect("popuptest", true, 3000);

Assert.IsTrue(this.manager.Browsers.Count == 2);  // This is true in this case, two browser windows are opened.

this.Action.ClickButton("close", true, false);  // Close is an html input button that cause the popup to close.

Assert.IsTrue(this.manager.Browsers.Count == 1);  // THIS FAILS!!!  There are still two browser windows in the Browsers collection.  But the close browser Visible = false now.

I would think logically if I am causing the browser to close by using an html control, the browser should be removed from the Browsers collection.

Note, if I loop, foreach (Browser browser in Manager.Current.Browsers, I see the two browsers and when browser is the popup I can call the browser.close() method, then it will be removed from the Browers collection, however I do not think I should have to program for this, but it should be part of the Click(IsClosing = True)

 

0
Stoich
Telerik team
answered on 22 Dec 2011, 01:56 PM
Hello Jamie,
it seems to me that the ClosesBrowser property is what you might be missing:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/knowledge-base/dialogs-popups/closes-browser-property.aspx

I've attached a small test that runs against this URL to demonstrate this. A few thing to point out about this test:
-notice there's no "Close popup window" step. That's because step 6 is set to ClosesBrowser=true and gets the job done
-notice there are 3 identical coded steps:
Log.WriteLine(Manager.Browsers.Count.ToString());
Run the test once and check out the Log. You'll see that this returned 1 initially. Then 2 after connecting to the popup. Then 1 again after disconnecting. In short: adding/removing browser instances worked as expected.

All the best,
Stoich
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Jamie
Top achievements
Rank 2
Answers by
Jamie
Top achievements
Rank 2
Stoich
Telerik team
Share this question
or