none
UIAutomation: AutomationElement can only be found by using AutomationElement.FromPoint method RRS feed

  • Dotaz

  • I'm kinda struggling while getting a ToolStrip button. I'm not able to get it by a Name property, It's only possible to get it by its coordinates. 

    There is a look at the UI. 

    Toolstrip consists of buttons and a progress bar. All of the ToolStrip buttons are causing the same problem described bellow. 

    When I do this the AutomationElement is found and returned:

    var aElemByCoordinates = AutomationElement.FromPoint(new System.Windows.Point(462, 877));

    But when I do this then a null is returned:

    TreeScope treescope =  TreeScope.Element | TreeScope.Children | TreeScope.Descendants;var aElemByName =  parentAutomationElement.FindFirst(treescope, new PropertyCondition(AutomationElement.NameProperty, aElemByCoordinates.Current.Name)); // How is that possible...?

    I'm able to get other ToolStrip buttons contained in the window except those contained in the ToolStrip. Controls are visible by using Inspect.

    Also there is another strange thing about the AutomationElement collected by coordinates. When I get its parent and then look into parent children then the AutomationElement (the toolstrip button element collected by coordinates) is not here. 
    Simply said, a parent doesn't have a child while the child has the parent as its parent.

    I'm really confused by the behavior of the automation element. Sometimes it acts like it exists but another time its not

    Lately me and my collegue find out that placing progressbar behind the buttons fixes the problem

    Does anyone have a clue what could be possibly causing this strange behaviour?



    • Upravený Olafvolafka středa 7. října 2020 5:21 Edit text
    pondělí 5. října 2020 13:35