Frage

I have a small application using wxWidgets, running on MS Windows. I'm using UI Automation to do automated testing. For the most part, this is going quite well. However, I've hit a snag.

For most widgets, it seems that the UIA "Name" property matches whatever the text on the widget is. (I don't know whether wxWidgets does this or whether UIA does it.) But for image buttons... yeah, no text. So what I want to do is add some kind of property to these widgets that makes them uniquely identifiable through UIA, without altering the visual appearance of the GUI.

I had hoped that simply setting the "name" property in the window designer would do this... but sadly no. Any ideas how I can fix this?

War es hilfreich?

Lösung

The name is not used at MS Windows level. The only thing which is the ID, so if you use fixed unique IDs (as opposed to specifying wxID_ANY when creating your windows), you should be able to find the window during run-time from them.

Edit: The ID can be queried from UIA using the AutomationIdProperty, like so:

string id = (string)widget.GetCurrentPropertyValue(AutomationElement.AutomationIdProperty);

Usually the string is a decimal number, but not always.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top