Skip to main content

UIAutomation: Getting child control are very slow RRS feed

  • Question

  • Hi guys,

    I'm using  UIAutomation for software testing at work. It's working well but I found a problem for this one application.

    It loads in around 1-2 seconds, and I am able to get the AutomationElement of its window in around 2 seconds. However the children automationelement of this window is only avalaible in around 10 seconds ( before that windowElement.FindAll(TreeScope.Children, Condition.TrueCondition) always returns an empty collection), even though the actual children controls are already visible in the GUI and the automationelement for the parent window is available long before that.

    The applicaiton is an old Win32 application in my company. The problem is only found with this application so far, UIAutomation works well with other applications

    What could be the cause of this slowness and how to avoid it? Is there a trick to make the children available to UIAutomation faster?

    Thursday, December 16, 2010 7:10 AM

All replies

  • Hi, Louis,

    FindAll() is not the only way to query for children.  Suppose you get a TreeWalker from the Automation object, go to the first child, and start walking through the siblings.  Does that work immediately?


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, December 16, 2010 11:34 PM
  • It's still as slow

    It still takes 9-10 seconds until GetFirstChild() to return something which is not null.

    Friday, December 17, 2010 7:13 AM
  • That's very strange - there isn't anything in UIA that would return null in some cases and a real object in others.  In the end, it all comes down to sending WM_GETOBJECT to the application and processing what the application returns.  It seems probably that the old Win32 app is responding differently to WM_GETOBJECT depending on how far it has gotten in its loading.  Since it is app-specific, I don't have much to suggest, other than to have your automation retry until it gets a good object back.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, December 17, 2010 4:16 PM
  • correction: it is a WinForm application not Win32
    Wednesday, December 22, 2010 6:17 AM