Identifying Standard Windows Objects

Applies to TestLeft 15.40, last modified on March 17, 2022
Search Patterns

To search for standard Windows controls in applications, you use search patterns of the WindowPattern type.

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

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

This pattern uses the following standard properties:

Property Type Description
ControlId Integer The object identifier that is returned by the Windows API function GetWindowLong() or GetDlgCtrlID().
Enabled Boolean Specifies whether the object is enabled or disabled. Disabled objects are usually shown grayed out.
Index Integer The object’s position in the front-to-back order (Z-order) within the parent object. Indexes start from 1 and are unique among sibling objects with the same window class (the WndClass property value). You can see this value in the TestLeft UI Spy.
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.
WndCaption String The text of the window’s title bar (if any), or the text of the control. This is the value returned by the Windows API function GetWindowText().
WndClass String The window class name of the object. For example, SysTreeView32, MDIClient, #32770 (dialog box). This is a value returned by the GetClassName() Windows API function.
Example

C#

IButton btnReplaceAll = Driver.Find<IProcess>(new ProcessPattern()
{
   ProcessName = "notepad"
}).Find<ITopLevelWindow>(new WindowPattern()
{
   WndClass = "#32770",
   WndCaption = "Replace"
}).Find<IButton>(new WindowPattern()
{
   WndClass = "Button",
   WndCaption = "Replace &All"
});

Visual Basic .NET

Dim btnReplaceAll As IButton = Driver.Find(Of IProcess)(New ProcessPattern() With {
    .ProcessName = "notepad"
}).Find(Of ITopLevelWindow)(New WindowPattern() With {
    .WndClass = "#32770",
    .WndCaption = "Replace"
}).Find(Of IButton)(New WindowPattern() With {
    .WndClass = "Button",
    .WndCaption = "Replace &All"
})

Java

Button btnReplaceAll = driver.find(TestProcess.class, new ProcessPattern() {{
    ProcessName = "notepad";
}}).find(TopLevelWindow.class, new WindowPattern() {{
    WndClass = "#32770";
    WndCaption = "Replace";
}}).find(Button.class, new WindowPattern() {{
    WndClass = "Button";
    WndCaption = "Replace &All";
}});

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