Search Patterns
To search for objects in Delphi and C++Builder VCL applications, you use search patterns of the VCLPattern
type:
.NET: The pattern belongs to the SmartBear.TestLeft.TestObjects.VCL
namespace.
Java: The pattern belongs to the com.smartbear.testleft.testobjects
package.
This pattern uses the following standard properties:
Property | Type | Description |
---|---|---|
ClassName |
String | The object’s class name, for example, TButton or TcxGrid. |
Enabled |
Boolean | Specifies whether the object is enabled or disabled. Disabled objects are usually shown grayed out. |
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. |
ObjectIdentifier |
String | The object ID is usually the object name that is specified by the developers in the application code. If the name is empty and the object is windowless, this is the object’s class name returned by TObject.ClassName . If two or more objects have the same non-empty ID, they have indexes appended to their IDs, for example, TdxBarButton, TdxBarButton_2, TdxBarButton_3, and so on. You can see this value in the TestLeft UI Spy.
|
Example
C#
IBar tdxRibbon = Driver.Find<IProcess>(new ProcessPattern()
{
ProcessName = "RibbonNotepadDemo"
}).Find<ITopLevelWindow>(new VCLPattern()
{
ClassName = "TfrmRibbonNotepadMain",
ObjectIdentifier = "frmRibbonNotepadMain"
}).Find<IBar>(new VCLPattern()
{
ClassName = "TdxRibbon",
ObjectIdentifier = "Ribbon"
});
Visual Basic .NET
Dim tdxRibbon As IBar = Driver.Find(Of IProcess)(New ProcessPattern() With {
.ProcessName = "RibbonNotepadDemo"
}).Find(Of ITopLevelWindow)(New VCLPattern() With {
.ClassName = "TfrmRibbonNotepadMain",
.ObjectIdentifier = "frmRibbonNotepadMain"
}).Find(Of IBar)(New VCLPattern() With {
.ClassName = "TdxRibbon",
.ObjectIdentifier = "Ribbon"
})
Java
Bar tdxRibbon = driver.find(TestProcess.class, new ProcessPattern() {{
ProcessName = "RibbonNotepadDemo";
}}).find(TopLevelWindow.class, new VCLPattern() {{
ClassName = "TfrmRibbonNotepadMain";
ObjectIdentifier = "frmRibbonNotepadMain";
}}).find(Bar.class, new VCLPattern() {{
ClassName = "TdxRibbon";
ObjectIdentifier = "Ribbon";
}});
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 C++Builder Applications for Testing
Preparing Delphi Applications for Testing