Identifying Visual Basic 6 Objects

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

To search for objects in Visual Basic 6 applications, you use search patterns of the VBPattern type.

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

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

This pattern uses the following properties:

Property Type Description
Enabled Boolean Specifies whether the object is enabled or disabled. Disabled objects are usually shown grayed out.
Index Integer Used for windowed objects. 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.
VBObjectName String The object name specified by the developers in the application code.
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.
Example

C#

IButton button = Driver.Find<IProcess>(new ProcessPattern()
{
   ProcessName = "VB6AppDemo"
}).Find<ITopLevelWindow>(new VBPattern()
{
   VBObjectName = "frmMain"
}).Find<IButton>(new VBPattern()
{
   VBObjectName = "cmdGetResults"
});

Visual Basic .NET

Dim button As IButton = Driver.Find(Of IProcess)(New ProcessPattern() With {
   .ProcessName = "VB6AppDemo"
}).Find(Of ITopLevelWindow)(New VBPattern() With {
   .VBObjectName = "frmMain"
}).Find(Of IButton)(New VBPattern() With {
   .VBObjectName = "cmdGetResults"
})

Java

Button button = driver.find(TestProcess.class, new ProcessPattern() {{
   ProcessName = "VB6AppDemo";
}}).find(TopLevelWindow.class, new VBPattern() {{
   VBObjectName = "frmMain";
}}).find(Button.class, new VBPattern() {{
   VBObjectName = "cmdGetResults";
}});

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