Identifying UI Automation Objects

Applies to TestLeft 4.72, last modified on December 21, 2020
Search Patterns

To search for objects identified via UI Automation, you use search patterns of the UIAPattern type.

.NET: The pattern belongs to the SmartBear.TestLeft.TestObjects.UIAutomation namespace.

Java: The pattern belongs to the com.smartbear.testleft.testobjects package.

This pattern uses the following properties:

Property Type Description
ClassName String The object’s class name. This is the value of the ClassName UI Automation property (UIA_ClassNamePropertyId) for that object.
Enabled Boolean Specifies whether the object is enabled or disabled. Disabled objects are usually shown grayed out.
FrameworkId String The name of the underlying UI framework. For example, Win32, WinForm, WPF, DirectUI. This is the value of the UI Automation property FrameworkId (UIA_FrameworkIdPropertyId) for that object.
LocalizedControlType String The object type in lowercase. For example, button, combo box, data grid. This is the value of the LocalizedControlType UI Automation property (UIA_LocalizedControlTypePropertyId) for that object.
ObjectGroupIndex Integer The object’s index (1-based) among sibling objects with the same ObjectIdentifier.
ObjectIdentifier String or
The object identifier is the value of one of the following UI Automation properties for that object, in order of preference:
  • Name (with spaces replaced by underscores)
  • AutomationID
  • ClassName
Visible Boolean Specifies whether the object is visible in the application. Objects that are out of screen bounds or overlapped by other objects are still considered visible.

You can use any combination of these properties in your UI Automation search patterns.



IControl link = Driver.Find<IProcess>(new ProcessPattern()
   ProcessName = "explorer"
}).Find<ITopLevelWindow>(new WindowPattern()
   WndClass = "CabinetWClass",
   WndCaption = "Programs and Features"
}).Find<IControl>(new UIAPattern()
   FrameworkId = "DirectUI",
   LocalizedControlType = "pane",
   ObjectIdentifier = "CPNavPanel"
}, 6).Find<IControl>(new UIAPattern()
   ClassName = "ControlPanelLink",
   ObjectIdentifier = "Install_a_program_from_the_network"

Visual Basic .NET

Dim link As IControl = Driver.Find(Of IProcess)(New ProcessPattern() With {
   .ProcessName = "explorer"
}).Find(Of ITopLevelWindow)(new WindowPattern() With {
   .WndClass = "CabinetWClass",
   .WndCaption = "Programs and Features"
}).Find(Of IControl)(new UIAPattern() With {
   .FrameworkId = "DirectUI",
   .LocalizedControlType = "pane",
   .ObjectIdentifier = "CPNavPanel"
}, 6).Find(Of IControl)(new UIAPattern() With {
   .ClassName = "ControlPanelLink",
   .ObjectIdentifier = "Install_a_program_from_the_network"


Control link = driver.find(TestProcess.class, new ProcessPattern() {{
   ProcessName = "explorer";
}}).find(TopLevelWindow.class, new WindowPattern() {{
   WndClass = "CabinetWClass";
   WndCaption = "Programs and Features";
}}).find(Control.class, new UIAPattern() {{
   FrameworkId = "DirectUI";
   LocalizedControlType = "pane";
   ObjectIdentifier = "CPNavPanel";
}}, 6).find(Control.class, new UIAPattern() {{
   ClassName = "ControlPanelLink";
   ObjectIdentifier = "Install_a_program_from_the_network";

Custom Properties

You can also specify custom properties by using the .add("propertyname", value) method of the pattern object. See Using Custom Properties in Search Patterns.

See Also

Understanding Object Identification

Highlight search results