Forum Discussion

littlebear's avatar
littlebear
Contributor
3 months ago

Script Test step having unexplainable delay

Hello all,

I am making a test that iterates through all the child objects of a certain object. I used TestComplete's example in the Child method documentation as my starting point, and I haven't changed much:

var w, i, wndChild;
  w = Aliases.browser.pageD365.sectionLanguage.panelRecentlyUsed;
  Log.Message(w.Name, w.FullName);
  w.Click();
  // Add a for loop that iterates through child objects
  for (i=w.ChildCount - 1; i >= 0; i--)
  {
    wndChild = w.Child(i);
    // Post the current child name to the test log
    Log.Message(wndChild.Name, "", 0);
    // Click on the Child Object
    wndChild.Click();
  }

If I remove Line 12, the test runs at a normal pace. However, if I use the current Line 12, or use this:

    w.Child(i).Click();

every time the test goes to run that step, it delays about 22 seconds. I know that the object it is looking for is clickable, seeing as it completes the step after that delay, and the test can run successfully. Additionally, TestComplete's test run status box in the top right does not change, and shows no sign of any unexpected delay. My guess is that the object recognition is taking a very long time for some reason, but it doesn't when looking for the same object in Line 10.

Thank you for your help and advice,

  • eykxas's avatar
    eykxas
    3 months ago

    Hi !

    Some times ago, I noticed that using NameMapping with a lot of objects, is incredibly slow, even if the hierarchy is correct. 

    So now, I avoid it almost completely (less than 10 objects), and no more slow down since.

  • My guess would be that the object isn't actually enabled when the attempt to click is made. 

    You can check that with Enabled

    https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/onscreen/enabled-property-onscreen-object.html

    You can also use Wait to look for the object and see if you can get access to it any faster. 

    https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/waiting-state-changes.html

  • JDR2500's avatar
    JDR2500
    Frequent Contributor

    Hi,

    Is "Extended Find" checked for any levels in that branch of your name mapping hierarchy (i.e. Aliases.browser.pageD365.sectionLanguage.panelRecentlyUsed)?  My experience is that translates to extra slow mode.  I avoid it at all costs.  It requires more work getting all the levels of hierarchy mapped but it worth it IMO.

    Name Mapping - Extended Search | TestComplete Documentation (smartbear.com)

    As Marsha suggested, it could also be the results of the object state.  However, I wouldn't expect a 22 second delay unless your auto-wait in the project properties is set really high.  I think five to ten seconds it the default.

    Lastly, are there a ton of child objects?  If there are a dozen that should be quick.  If there are a thousand that's a different story.  We have a tree control in our app that has ~10000 children.  It takes several minutes to click anything in that tree.

    Best regards, John

    • littlebear's avatar
      littlebear
      Contributor

      While the actual DOM object only has about 20 children (not including the children's children, and their children, etc.), the Namemapping object has a lot of "siblings". Basically, there is my page object: page1, and page1 has over 300 children, the object w being one of them. If you think that's the place to start, I'm going to try to build more hierarchy into the Namemapping file and see if that improves performance.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    It looks like you have identified the issue - now ask yourself, does the child object have a click method? Is the child object visible? and is it enabled (as Marsha_R has mentioned)? For TestComplete to perform the appropriate action?

    All standard objects will have the Name property. Hence, this will work fine.

    The delay is most likely relating to your project settings for playback,

    Error messages in the log should give you an indication as to what the possible cause is.

    • littlebear's avatar
      littlebear
      Contributor

      Thank you for your advice! Because the test does run, evidently the object is clickable, and the objects is visible and enabled for a user the whole time. I will definitely investigate further about those properties. 

      The strange things is that when the Auto-wait timeout is running, there is always an indication from that status box in the top right, where it will say "waiting until object x is visible" or "searching for object x". In this case, there just the normal message even when nothing is happening during the delay:

      I'm going to try to shrink down my Namemapping bloat, and I will get back to all of you about how that works.

      Thank you,

      • eykxas's avatar
        eykxas
        Regular Contributor

        Hi !

        Some times ago, I noticed that using NameMapping with a lot of objects, is incredibly slow, even if the hierarchy is correct. 

        So now, I avoid it almost completely (less than 10 objects), and no more slow down since.