Search Patterns
TestLeft allows you to test .NET Windows Forms and VCL.NET applications.
To search for WinForms objects, use search patterns of the WinFormsPattern
type. To search for VCL.NET objects, use the VCLNETPattern
search pattern type.
.NET: The patterns belong to the SmartBear.TestLeft.TestObjects.WinForms
and SmartBear.TestLeft.TestObjects.VCLNET
namespaces correspondingly.
Java: The patterns belong to the com.example.smartbear.testleft.testobjects
package.
These patterns use the following properties:
Property | Type | Description |
---|---|---|
ClrFullClassName |
String | The object’s full class name including the namespace name. For example, System.Windows.Forms.Button. |
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. |
VCLNETControlName |
String | Used only for VCL.NET objects. The object name specified by the developers in the application code. This is the Name native property of the object. |
WinFormsControlName |
String | Used only for WinForms objects. The object name specified by the developers in the application code. This is the Name native property of the object. |
WndCaption |
String | The object text. For example, window title, button text, text in a text box, check box caption, and so on. |
Example
C#
IButton button = Driver.Find<IProcess>(new ProcessPattern()
{
ProcessName = "Orders"
}).Find<ITopLevelWindow>(new WinFormsPattern()
{
WinFormsControlName = "OrderForm"
}).Find<IButton>(new WinFormsPattern()
{
ClrFullClassName = "System.Windows.Forms.Button",
WndCaption = "OK"
});
Visual Basic .NET
Dim button As IButton = Driver.Find(Of IProcess)(New ProcessPattern() With {
.ProcessName = "Orders"
}).Find(Of ITopLevelWindow)(New WinFormsPattern() With {
.WinFormsControlName = "OrderForm"
}).Find(Of IButton)(New WinFormsPattern() With {
.ClrFullClassName = "System.Windows.Forms.Button",
.WndCaption = "OK"
})
Java
Button button = driver.find(Process.class, new ProcessPattern() {{
ProcessName = "Orders";
}}).find(TopLevelWindow.class, new WinFormsPattern() {{
WinFormsControlName = "OrderForm";
}}).find(Button.class, new WinFormsPattern() {{
ClrFullClassName = "System.Windows.Forms.Button";
WndCaption = "OK";
}});
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
Preparing .NET Applications for Testing