locked
How To Make playback wait page to be completely loaded? RRS feed

  • Question

  • I'm automating tests for a website that, after you do your first selection, take a hell of a time to load.

    Sometimes closer to 4 minutes.

    The menus and links are already displayed BUT, if you click on them and the page is not fully loaded (some java monster running on behind, go figure), the actions are not performed.

    So, here's what the use case would look like:

     - Select app

     - Wait for the page to be fully loaded

     - Click on menu item desired

     - Perform given action.

     

    Code was looking like this:

                this.UIMap.SelectAPP("Generator");
                Playback.PlaybackSettings.WaitForReadyTimeout = 240000;
                Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.AllThreads;
                UIMap.UIWindow.WaitForControlReady();

    Didn't work cause it would click before page was loaded.

    Used Playback.Wait(240000); and it works but it's not the best solution.

    The best for me would be to have a response for the browser that the page is loaded. How to?


    Otto Sporteman
    Tuesday, March 22, 2011 6:50 PM

Answers

  • I worked with Otto offline and gave him the solution for this particular scenario.

    Playback.PlaybackSettings.SearchTimeout=1600000;
    
    UIMap.UIWindow.UIDocument.WaitForControlReady(1600000);
    
    

    Setting the SearchTimeout is required as there is a bug that ignores the WaitForControlReady timeout if the control was already found/used in earlier calls.

    The timeout is set higher here since in this particular case, the state of the web page does not change for a long time though the page is still loading.  


    Thanks, Neeraj
    Monday, March 28, 2011 1:19 PM
    Moderator

All replies

  • Nobody?
    Otto Sporteman
    Thursday, March 24, 2011 11:46 AM
  • try moving your WaitForControlReady() down from the Window to the HtmlDocument.

     

    if UIWindow is a Browser object then see below (if not look at your UI maps to find the control that's actually loading a browserwindow isn't what isn't ready while a page is loading.

     

    UIMap.UIWindow.CurrentDocumentWindow.WaitForControlReady()

    • Proposed as answer by Chris675 Thursday, March 24, 2011 2:46 PM
    Thursday, March 24, 2011 2:46 PM
  • Hi Chris, tried that but got no success.

    It seems the big "monster" is being loaded on another document or in a hidden applet  that I cannot inspect on.

    The  best approach would be to have a Browser.WaitForLoadComplete() but it seems to be impossible :-(


    Otto Sporteman
    Friday, March 25, 2011 3:09 PM
  • What does the log say? Can  you send the snippet of the log where the wait for ready is successful?
    Thanks, Neeraja
    Friday, March 25, 2011 6:00 PM
    Moderator
  • the only wait that gets a successful output is

    Playback.Wait(240000);

    If I use

    UIMap.UIWindow.UIDocument.WaitForControlReady(240000);

    it executes the next step (a click) without the document being completely loaded.

    The error goes like this, but it's a common "couldn't finde the object error":

    Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
    TechnologyName:  'Web'
    ControlType:  'ComboBox'
    TagName:  'SELECT'
    Id:  'selectProvider'
    Name:  ''
     Failed to find any control that matched the search condition Id='selectProvider' && Name='' && ControlType='ComboBox' ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

    Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.FindAllDescendants(String bstrQueryId, Object& pvarResKeys, Int32 cResKeys, Int32 nMaxDepth)
    Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindAllScreenElement(String queryId, Int32 depth, Boolean singleQueryId, Boolean throwException)
    Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindScreenElement(String queryId, Int32 depth)
    Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
    Microsoft.VisualStudio.TestTools.UITesting.Playback.MapControlNotFoundException(COMException ex, IPlaybackContext context)
    Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowComException(COMException innerException, IPlaybackContext context)
    Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, IPlaybackContext context)
    Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, String queryId)
    Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
    Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetUITestControlRecursive(Boolean useCache, Boolean alwaysSearch, ISearchArgument searchArg, IList`1 windowTitles, Int32& timeLeft)
    Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetElement(Boolean useCache, ISearchArgument searchArg)
    Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.Search(ISearchArgument searchArg)
    Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindInternal()
    Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindControlIfNecessary()
    Microsoft.VisualStudio.TestTools.UITesting.UITestControl.Click(MouseButtons button, ModifierKeys modifierKeys, Point relativeCoordinates)
    Microsoft.VisualStudio.TestTools.UITesting.Mouse.ClickImplementation(UITestControl control, MouseButtons button, ModifierKeys modifierKeys, Point relativeCoordinate)
    Microsoft.VisualStudio.TestTools.UITesting.Mouse.ClickImplementationWrapper(UITestControl control, MouseButtons button, ModifierKeys modifierKeys, Point relativeCoordinate)
    Microsoft.VisualStudio.TestTools.UITesting.Mouse.Click(UITestControl control, Point relativeCoordinate)
    Pilot.UIMap.NavigateToEntitlementListAndMaintenance() in C:\Users\otto_sporteman\documents\visual studio 2010\Projects\Project\UIMap.cs: line 839
    Project.TestCases.Test() in C:\Users\otto_sporteman\documents\visual studio 2010\Projects\Project\TestCases.cs: line 854

     


    Otto Sporteman
    Friday, March 25, 2011 6:09 PM
  • Can you enable the logs using instructions at http://blogs.msdn.com/b/gautamg/archive/2009/11/29/how-to-enable-tracing-for-ui-test-components.aspx and send the Wait for ready related logs before this failure?
    Thanks, Neeraja
    Friday, March 25, 2011 6:26 PM
    Moderator
  • I wouldn't like to publish the log here, can I send you through mail?


    Otto Sporteman
    Friday, March 25, 2011 6:46 PM
  • Sure. You can send the log to me at neerajarATmicrosoftDOTcom.
    Thanks, Neeraja
    Friday, March 25, 2011 6:55 PM
    Moderator
  • I worked with Otto offline and gave him the solution for this particular scenario.

    Playback.PlaybackSettings.SearchTimeout=1600000;
    
    UIMap.UIWindow.UIDocument.WaitForControlReady(1600000);
    
    

    Setting the SearchTimeout is required as there is a bug that ignores the WaitForControlReady timeout if the control was already found/used in earlier calls.

    The timeout is set higher here since in this particular case, the state of the web page does not change for a long time though the page is still loading.  


    Thanks, Neeraj
    Monday, March 28, 2011 1:19 PM
    Moderator
  • Thanks Neeraja, worked just fine once we got around this bug! :)

    Otto Sporteman
    Monday, March 28, 2011 1:32 PM
  • Exact issue encountered.

     

    Works perfect with the resolution suggested by Neeraja. Thanks!

     

    Regards,

    Tushar Palande

    Monday, May 30, 2011 8:31 AM
  • Hi Neeraja,

    I have the very same issue.

    Where do you enter the commands you suggested?

    Is it in the UIMap or test method?

    I have 10+ UI maps, and I need to call the wait function in the reusable functions called from the test methods.

    Cheers,

    Fred

    Wednesday, December 12, 2012 10:53 PM