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:


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


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.