Question

Problems with assigning AutomationIds to elements of TreeListView

Posted 3 months ago by Avatar Bjoern

Hi,

we are automating our user interface for testing purposes. At the moment we're trying to automatically use our tree control so that we can expand, collapse and invoke (click) its elements.

For that, we need to assign dynamic AutomationId's to our tree items.

The tree is Actipro control based and we're kind of stuck trying to assign these AutomationIds to our tree elements.
The tree itself consist of a TreeListView and it contains an ItemAdapter with the items we want to access in our UI.

<grids:TreeListView x:Name="ListOfTreeItems" RootItem="{Binding RootTreeItem}" [...]

        <grids:TreeListView.ItemAdapter>
            <local:TreeListAdapter x:Name="ItemAdapter"
              ChildrenBinding="{Binding VisibleItems, Mode=OneTime}"             
            />
        </grids:TreeListView.ItemAdapter>

</grids:TreeListView>

 

Is it somehow possible to assign a dynamically generated AutomationId to each individual item in the tree?

Is it generally possible to access the Actipro TreeListView and its Items via UI Automation as an automation element of type TreeControlType?

 

Thanks in advance for any advice!


Comments (3)

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA

Hello,

I first wanted to make a note that in our latest 2018.1 build, we added some UIA peers so that tree list view item peers are directly under the tree list view peer.

While we do support that in the latest build, the UIA peers aren't going to represent the tree structure.  The reason is that items in the control are actually a virtualized flat list with the hierarchy structure maintained behind the scenes.  This keeps the control able to render very fast in a virtualized way.  Due to the virtualization, there will likely only be UIA peers available for the item containers (TreeListViewItem controls) that are currently visible or nearly visible.

There is no automation ID set on the item peers by default.  But you could override the TreeListView.PrepareContainerForItemOverride method and assign an automation ID there.  That might do the trick.


Actipro Software Support
Posted 3 months ago by Bjoern

Hello,

your suggestion worked! I created a custom class that overrides the method, calls the base and then sets the AutomationId:

public class TreeListViewOverride : TreeListView
  {
    protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
    {
      base.PrepareContainerForItemOverride(element, item);      
      AutomationProperties.SetAutomationId(element, "customAutomationId");
    } 
  }

Afterwards I used this class in the XAML file instead of the TreeListView.

Is there a way to invoke the expand events on these list items or at least get the expand button? Currently the buttons all got the same AutomationId and can't be found by UI Automation.

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA

Hello,

There isn't right now but we will update the UIA peers for items to support the ExpandCollapse pattern for the next build.  


Actipro Software Support
Information The latest build of this product (2018.1 build 0673) was released 7 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.