Bugzilla – Bug 540889
AutomationId is not implemented as what Microsoft did
Last modified: 2009-09-22 03:45:04 UTC
On Windows/MS .Net, for a winform control, the AutomationElement.AutomationId is the name of the winform control. So I can use following code to find a TextBox control whose name is "txtCommand": var txtCommand = win.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElementIdentifiers.AutomationIdProperty, "txtCommand")); But with our implementation, the AutomationId becomes a integer like "2" or "15" etc, and the former search will fail to find the textbox. BTW, since in most cases a TextBox's NameProperty is an empty string, therefore it becomes difficult to find a TextBox without the help of AutomationId.
Realted mono-a11y emails: [Matt, Sep 18] Hey, all On Windows/MS .Net, for a winform control, the AutomationElement.AutomationId is the name of the winform control. So I can use following code to find a TextBox control whose name is "txtCommand": var txtCommand = win.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElementIdentifiers.AutomationIdProperty, "txtCommand")); But with our implementation, the AutomationId becomes a integer like "2" or "15" etc, and the former search will fail to find the textbox. So is it OK for us to implement AutomationId like this? BTW, since in most cases a TextBox's NameProperty is an empty string, therefore it becomes difficult to find a TextBox without the help of AutomationId. [Sandy, Sep 19] Matt, Please file a bug about this so we can fix it in UIAutomationWinforms. Both AutomationId and RuntimeId are incorrectly implemented there. Also, we have code (maybe in UiaAtkBridge, too) that assumes AutomationId should be unique (that code should instead use RuntimeId). From MSDN: "The AutomationIdProperty of an element is always the same in any instance of the application on any machine, regardless of the local language. If the property is supported by the element, the value is unique among sibling elements but not necessarily unique on the desktop. For example, multiple instances of an application, or multiple folder views in Microsoft Windows Explorer, may contain elements with the same AutomationIdProperty, such as "SystemMenuBar". Instances of user interface (UI) elements are uniquely identified on the desktop by their RuntimeIdProperty properties."