Problem

If you are reading this blog most likely means you have been through the same unsuccessful experience I had of trying to get a WPF ItemsControl control via automation ID using TestStack.White API (v0.13.3) in order to carry on some UI test automation.

Acquiring a WPF ListBox via automation ID using White is simple job. Unfortunately accessing ItemsControl doesn’t work the same way. A WPF ListBox is ItemsControl but not the other way around.

Even treating it as a White custom control, I had no luck:

Solution

So here is a solution, there are other ones like using automation peer.

screenshot-2016-12-19-17-09-41

Most likely getting hold of the ItemsControl is not helpful enough, hence we try to get access of its items instead. By assigning a dynamic ID per item using a WPF converter.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *