1

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?

MathematicalOrchid
  • 61,854
  • 19
  • 123
  • 220

1 Answers1

1

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.

MathematicalOrchid
  • 61,854
  • 19
  • 123
  • 220
VZ.
  • 21,740
  • 3
  • 39
  • 42
  • It appears the IDs are already fixed. (Pretty random-looking, but fixed.) Any idea where I need to look in UIA to dig this up? – MathematicalOrchid Feb 03 '14 at 16:39
  • Added the necessary code to the answer + accepted answer. – MathematicalOrchid Feb 03 '14 at 17:01
  • Notice that you always have _some_ IDs, of course, but if the source uses `wxID_ANY` the IDs may be different on the next run unless the order of creation of all windows is exactly the same. – VZ. Feb 03 '14 at 23:30