Varun S
Varun S

Reputation: 597

UI Automation Verify for finding AutomationId of elements

I am trying to automate testing an application written in C++. I use UI Automation: http://msdn.microsoft.com/en-us/library/ms747327.aspx I used UIAVerify to find automationIds of some elements but some elements are showing as disabled(grayed-out) in the tool.

Does it mean interactions for some elements are not automatable? How to automate interaction for an element which does not have a AutomationId value?

EDIT : I am trying to use automation to click on a control that has ControlType.Custom and has Name property set for it. Is there a way to do this? I tried these two ways, both fail:

method 1:

//using framework white
var button = window.Get(SearchCriteria.ByControlType(ControlType.Custom).AndByText ("<Name Property>"));

method 2:

//using Automation Framework
aeCtrl = aeParentPanel.FindFirst(TreeScope.Children,
                            new PropertyCondition(AutomationElement.NameProperty, "<Name Property>"));

Upvotes: 1

Views: 5332

Answers (1)

BrendanMcK
BrendanMcK

Reputation: 14498

From the "How To Use UI Verify" Word .doc file that's linked to from the UIA Verify page on codeplex:

Note A dimmed (unavailable) node in the Automation Elements Tree indicates that the element is a member of the UI Automation Raw View but does not meet the conditions necessary to be considered a member of either the Content View or Control View. However, the element can still be tested from Visual UI Automation Verify. For more information, see the UI Automation Tree Overview.

What this basically means is that these elements are 'chrome' items, they are things like menu bars or scrollbars, rather than content such as list items. They are still there and can be tested.

--

Not every element has an AutomationID. It's really up to the developer to set these as appropriate for use in testing. In some cases, they come from the underlying framework: for example, for Win32 controls, the Control ID - if present - is used to generate the AutomationID. In WPF, you have to set the deverloper has to assign it via the AutomationProperties.AutomationId Attached Property.

Typically its only set for controls in dialogs, and is used to distinguish between them. Items within a control - eg. items within a list box - are usually identified by their Name instead (or Value, for other controls). This is especially the case with items that are generated from an external source - such as a list containing filenames - since there's no reasonable way AutomationIDs could be assigned in advance there.

Upvotes: 5

Related Questions