Identifying Text Objects (Text Recognition)

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

To search for objects identified via Text Recognition, you use search patterns of the TextPattern type.

.NET: The pattern belongs to the SmartBear.TestLeft.TestObjects.TextRecognition 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 The object index among sibling objects with the same text. Objects are indexed from left to right, and in the same bucket from top to bottom.
Text String The object text.
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 Text Recognition search patterns.

Example

C#

Driver.Options.TextRecognition.AddWindow("TdxBarControl");

IControl fileMenu = Driver.Find<IProcess>(new ProcessPattern()
{
   ProcessName = "Orders"
}).Find<IWindow>(new WindowPattern()
{
   WndClass = "TdxBarControl",
   WndCaption = "MainMenu"
}, 2).Find<IControl>(new TextPattern()
{
   Text = "File"
});
fileMenu.Click();

Visual Basic .NET

Driver.Options.TextRecognition.AddWindow("TdxBarControl")

Dim fileMenu As IControl = Driver.Find(Of IProcess)(new ProcessPattern() With {
   .ProcessName = "Orders"
}).Find(Of IWindow)(new WindowPattern() With {
   .WndClass = "TdxBarControl",
   .WndCaption = "MainMenu"
}, 2).Find(Of IControl)(new TextPattern() With {
   .Text = "File"
})
fileMenu.Click()

Java

driver.getOptions().getTextRecognition().addWindow("TdxBarControl");

Control fileMenu = driver.find(TestProcess.class, new ProcessPattern() {{
   ProcessName = "Orders";
}}).find(Window.class, new WindowPattern() {{
   WndClass = "TdxBarControl";
   WndCaption = "MainMenu";
}}, 2).find(Control.class, new TextPattern() {{
   Text = "File";
}});
fileMenu.click();

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