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

Focus between windows handling.

11 Answers 374 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
algot
Top achievements
Rank 1
algot asked on 05 Dec 2011, 02:11 PM
My application is opened windows in following order:
Window1 opens Window2 which opens Window3
W1 - W2 - W3

After I close Window3 Telerik doesn't "see" Window2.

I have following test steps:
1. Opening W1
// Connect to pop-up window : '/Site/main.aspx?'
Manager.WaitForNewBrowserConnect("/Site/main.aspx?", true, 5000);
Manager.ActiveBrowser.WaitUntilReady();
ActiveBrowser.Window.SetFocus();
2. Opening W2
// Connect to modal pop-up window : Look Up Records -- Webpage Dialog
if ((ActiveBrowser.BrowserType == BrowserType.InternetExplorer))
{
    ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions ieActions = ((ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions)(ActiveBrowser.Actions));
        ieActions.ConnectIEDialog("Look Up Records -- Webpage Dialog", 5000);
}
Manager.WaitForNewBrowserConnect("/Site/_controls/lookup/lookupinfo.aspx?LookupStyle=multi&browse=0&objecttypes" +
                "=4300", true, 5000);
Manager.ActiveBrowser.WaitUntilReady();
3. Opening W3
// Connect to modal pop-up window : Add Marketing Lists to Campaign -- Webpage Dialog
if ((ActiveBrowser.BrowserType == BrowserType.InternetExplorer))
{
        ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions ieActions = ((ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions)(ActiveBrowser.Actions));
        ieActions.ConnectIEDialog("Add Marketing Lists to Campaign -- Webpage Dialog", 5000);
}
Manager.WaitForNewBrowserConnect("/Sitecore/_controls/lookup/lookupinfo.aspx?LookupStyle=multi&browse=0&objecttypes" +
                "=4300", true, 5000);
Manager.ActiveBrowser.WaitUntilReady();
ActiveBrowser.Window.SetFocus();
4. Closing W3
// Close modal pop-up window : Add Marketing Lists to Campaign -- Webpage Dialog
ActiveBrowser.Close();

After closing W3 Window2 get focus but Telerik lost it and can't do following steps.
How I could get my test working?

11 Answers, 1 is accepted

Sort by
0
algot
Top achievements
Rank 1
answered on 07 Dec 2011, 03:58 PM
Does anybody have any advise?
Problem is that Telerik doesn't switch to W2 and DOM has content from W3.
InError set by the client. Client Error:
System.ArgumentNullException: Value cannot be null.
Parameter name: SetCurrentDocumentMarkup. The document object is null. Unable to get markup. Probably the Html Document was closed prior to executing the action.


Any solutions?
0
Anthony
Telerik team
answered on 09 Dec 2011, 12:31 AM
Hi Alexander,

It's unclear how all your code fits together. I suspect it isn't organized correctly. Here's sample code that worked for me where a parent page (W1) opens Modal1 (W2), and then Modal2 is opened (W3) from W2:

[TestMethod]
public void ModalPopup2()
{
   Manager.LaunchNewBrowser();
   ActiveBrowser.NavigateTo("c:\\html\\modal.html");
 
   Manager.SetNewBrowserTracking(true);
 
   Find.ByContent<HtmlButton>("Show Modal Example").MouseClick(); //load Modal1
 
   if (ActiveBrowser.BrowserType == BrowserType.InternetExplorer)
      {
          ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions ieActions = ((ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions)(ActiveBrowser.Actions));
          ieActions.ConnectIEDialog("Modal1 -- Webpage Dialog", 5000);
 
          Manager.WaitForNewBrowserConnect("codefrog.html", true, 5000);
          Assert.IsTrue(ActiveBrowser.IsIEDialog);
                 
          Find.ByContent<HtmlButton>("Show Modal Example2").MouseClick(); //Load Modal2 from Modal1
 
          if (ActiveBrowser.BrowserType == BrowserType.InternetExplorer) //second IF nested inside first IF
             {
                 ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions ieActions2 = ((ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions)(ActiveBrowser.Actions));
                 ieActions2.ConnectIEDialog("Modal2 -- Webpage Dialog", 5000); //Give second ieActions2 variable unique name
 
                 Manager.WaitForNewBrowserConnect("comma.html", true, 5000);
                 Assert.IsTrue(ActiveBrowser.IsIEDialog);
 
                 ActiveBrowser.Close(); //Close Modal2
             }
 
             Find.ByAttributes<HtmlAnchor>("href=http://www.bing.com").Click(); //Click a link unique to Modal1 to prove it is current ActiveBrowser, then close it
             ActiveBrowser.Close();
                 
   }
 
                       
}
 

Kind regards,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
algot
Top achievements
Rank 1
answered on 09 Dec 2011, 09:19 AM
Thank you very much for your answer, I will try it later.

My code is auto-generated by Telerik.

Now I'm  struggling with 3 window handling if test is generated by recorder. I hope "Find" will help me, but it very strange why this functionality doesn't work out-of-box.
0
algot
Top achievements
Rank 1
answered on 09 Dec 2011, 09:55 AM
I made video capture of problem part of my test
http://screencast.com/t/_4v0YkyWgSS_
0
Anthony
Telerik team
answered on 12 Dec 2011, 06:15 PM
Hi Alexander,

Thank you for the screen recording. It clarifies your scenario that you're using standard steps through the Standalone version's UI and not crafting entirely in code as I initially thought.

Step 31 is trying to connect to an HTML Popup with a partial URL of:

  •  /Sitecore/main.aspx?

This matches that popup's URL when it is first launched. However, the video indicates that after its content loads, the URL changes to:

  • https://vs4crm2011.crm5test.sitecore.net/?etc=... 

I suspect that during Test Execution there isn't enough time for Test Studio to connect to the popup before its URL changes. Try changing the PopUrl for step 31 to contain a partial match for the second URL.

Kind regards,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
algot
Top achievements
Rank 1
answered on 13 Dec 2011, 09:37 AM
I changed URL and it works now. Thank you very much.

Also why Telerik handle URL such way if window have another URL?

And how can I determine URL of window instead of view its header directly?
0
Accepted
Anthony
Telerik team
answered on 13 Dec 2011, 05:02 PM
Hello Alexander,

When you recorded the test and initially loaded the popup it contained URL1, so that's what Test Studio recorded. The Connect to popup window step was then in place with URL1, and it's not going to automatically update when the popup redirects to URL2. That's why that step required a manual change.

Your last question is best asked to your developers. I'm sure your app's code contains the URL information. As a tester, it's probably easiest to visually verify via the window's header, as we've just experienced.

Regards,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
algot
Top achievements
Rank 1
answered on 15 Dec 2011, 12:12 PM
Now I face with another problem with window's focus handling
http://screencast.com/t/jNKr0Vq2Pr

I have focus on window, try to close it by partial URL
http://screencast.com/t/lHGjzYm5

but test step is failed with
Cannot find Browser host with Url: '?etc=4212&extraqs='.
Attempted to close Browser: 'https://vs4crm2011.crm5test.sitecore.net/Sitecore/Activities/act_dlgs/convert_activity.aspx?activityType=4212&;ownerId=%7b2741E56C-363A-DF11-9A3A-00155D28151F%7d&ownerType=8&subject=call%20gage

Why I can't close browser?
0
Anthony
Telerik team
answered on 15 Dec 2011, 07:41 PM
Hi Alexander,

It seems the Close modal pop-up window step was either not recorded or removed. This is why the focus has remained on the modal and not back to the HTML popup.

The issue is with step 14 that clicks the Cancel button. This actually closes the Modal window. Normally setting this step's ClosesBrowser property to True will handle this situation. However I reproduced this scenario with local files where this doesn't work as expected. The focus remains on the Modal window and thus the HTML popup cannot be found and closed. I logged a bug report on this. You can find the PITS Issue here: Public URL.  

In the meantime, try disabling the "Click Button_Cancel" step and putting a Close modal pop-up window: Convert Task To Opportunity -- Webpage Dialog step in its place. 

All the best,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
algot
Top achievements
Rank 1
answered on 16 Dec 2011, 10:33 AM
Replacing cancel to close helped.
But how I should do if I need to press OK and window will be closed? Set "ClosesBrowser property to True" doesn't help.
0
Anthony
Telerik team
answered on 16 Dec 2011, 03:41 PM
Hello Alexander,

That's the exact issue I filed the bug for. Setting ClosesBrowser to True should work in this scenario, but it doesn't. We'll strive to fix that bug soon.

Regards,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
algot
Top achievements
Rank 1
Answers by
algot
Top achievements
Rank 1
Anthony
Telerik team
Share this question
or