Visibility parameter of WPF control not visible with UI Automation?

412 Views Asked by At

I started writing test for a WPF application with FlaUI (UI Automation framework). Now I want to get the Visibility value of a couple of buttons.

These buttons are located on the same position in the WPF window. The first is a start button which will start a measurement. When clicked, the measurement button is replaced with a stop button. The visibility of these buttons are set in the code behind of the xaml and needs to be checked/verified.

With FlaUI I only get IsEnabled boolean and OffScreen boolean. But when using the Offscreen parameter, this boolean is not set or is set to the correct value for a couple of seconds but is changed again while the measurement is still running.

I also tried other ways, like looking for a clickable point of the not visible button. But those are not working.

Can this be done without extending the button class with an AutomationPeer and exposing a ValuePattern? I googled a bit but cannot find an (decent) answer. Hopefully someone can help.

1

There are 1 best solutions below

0
On

I think an important part of your question is the word "replaced". Commonly a program draws one set of controls (in your case the start button) and later draws another set. Possible on top to hide the first, or possible by deleting them.

Commonly controls, including buttons, are drawn within other containing controls and so it may be that the button controls are not there at all, hence the visibility checks should be done on the parent or ancestor controls.

This Q&A seems related to the problem you are having and it may provide some more insight.