Focus between windows handling.

12 posts, 1 answers
  1. algot
    algot avatar
    57 posts
    Member since:
    Nov 2011

    Posted 05 Dec 2011 Link to this post

    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?
  2. algot
    algot avatar
    57 posts
    Member since:
    Nov 2011

    Posted 07 Dec 2011 Link to this post

    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?
  3. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 08 Dec 2011 Link to this post

    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
  4. algot
    algot avatar
    57 posts
    Member since:
    Nov 2011

    Posted 09 Dec 2011 Link to this post

    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.
  5. algot
    algot avatar
    57 posts
    Member since:
    Nov 2011

    Posted 09 Dec 2011 Link to this post

    I made video capture of problem part of my test
    http://screencast.com/t/_4v0YkyWgSS_
  6. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 12 Dec 2011 Link to this post

    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
  7. algot
    algot avatar
    57 posts
    Member since:
    Nov 2011

    Posted 13 Dec 2011 Link to this post

    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?
  8. Answer
    Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 13 Dec 2011 Link to this post

    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
  9. algot
    algot avatar
    57 posts
    Member since:
    Nov 2011

    Posted 15 Dec 2011 Link to this post

    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?
  10. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 15 Dec 2011 Link to this post

    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
  11. algot
    algot avatar
    57 posts
    Member since:
    Nov 2011

    Posted 16 Dec 2011 Link to this post

    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.
  12. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 16 Dec 2011 Link to this post

    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
Back to Top