Text Properties
Searching for or reading text on your system under test (SUT) using optical character recognition (OCR) requires use of a text property list. These property lists have a wide variety of properties you can include, depending on the text you are working with and the purpose of your search.
See Working with OCR to learn how to work with the most commonly used text properties in more detail.
This page covers the available OCR properties as they can be addressed in-line with SenseTalk scripting. You can also adjust your OCR properties from several locations in Eggplant Functional:
What is a Text Property List?
A text property list is a description of text on the SUT. Every text property list must contain the Text
property, which defines the actual text string you are looking for, and any number of the additional properties described below. Any property that is not included in the property list defaults to your Text Preferences settings.
The following text properties can be used with any text property list:
- Text:
Text string
. The text string that you want to find on the SUT. (Required.) - TextStyle:
Text-style name
. A group of predefined text properties. (For more information, see The Find Text Panel.)
OCR Text Properties Reference Table
Use the table below as a reference when working with OCR. It is a complete list of all supported SenseTalk properties for use with OCR. Some properties are available for reading and searching, while some are specific to one or the other. The type of value passed to the property is also included. Click the name of the property for its full description (a full description list is included on this page below the table). For more in-depth information on how to use the most common OCR properties, see Succeeding with OCR.
A boolean
value is like a toggle switch with two possible values; Yes/No values are accepted as well as On/Off.
Property | Searching | Reading | Value |
---|---|---|---|
AggressiveTextExtraction | Yes | Yes | Boolean |
CaseSensitive | Yes | No | Boolean |
Contrast | Yes | Yes | Boolean |
ContrastColor | Yes | Yes | A color (see Color Values in SenseTalk) |
ContrastTolerance | Yes | Yes | 0-100 / Default 45 |
DPI | Yes | Yes | Integer |
EnhanceLocalContrast | Yes | Yes | Boolean |
ExtraWords | Yes | Yes | A string or list of words |
IgnoreNewLines | Yes | No | Boolean |
IgnoreSpaces | Yes | No | Boolean |
IgnoreUnderscores | Yes | No | Boolean |
InvertImage | Yes | Yes | Boolean |
Language | Yes | Yes | A language name as specified in OCR Language Support (case sensitive). |
LowResolutionMode | Yes | Yes | Boolean |
Multiline | No | Yes | Boolean |
PreferDictionaryWords | Yes | Yes | Boolean |
PreferredPattern | Yes | Yes | Regular expression string (see Using Patterns in SenseTalk) |
PreferredWords | Yes | Yes | A string or list of words |
ProhibitedWords | Yes | Yes | A string or list of words |
SearchRectangle | Yes | No* | A pair of coordinates or captured images defining a rectangle |
TextDifference | Yes | No | Integer |
TextRotation | Yes | Yes | One of four predefined values |
Trim | No | Yes | Boolean |
TrimBorder | No | Yes | Integer |
TrimColor | No | Yes | A color (see Color Values in SenseTalk) |
TrimTolerance | No | Yes | Integer |
TrimWhitespace | No | Yes | Boolean |
ValidCharacters | No | Yes | Boolean |
ValidPattern | Yes | Yes | Regular expression string (see Using Patterns in SenseTalk) |
ValidWords | Yes | Yes | A string or list of words |
* You do not need to set a SearchRectangle
property with ReadText
because ReadText
already takes a rectangle by default. This property can also be set with standard image searches; for more on this, see Image References.
OCR Property Definitions
AggressiveTextExtraction
Type: Boolean
. Enable this property if you want OCR to extract as much text from the image as possible.
AggressiveTextExtraction Example
-- AggressiveTextExtraction example
Log ReadText(("TLImage","BRImage"), AggressiveTextExtraction:on)
CaseSensitive
Type: Boolean, Default: off
. Whether or not Eggplant Functional considers case in text searches. Enable this property to force text searches to respect case and only find text that matches your text string’s capitalization exactly. This property is for searching for text, not reading text.
CaseSensitive Example
-- caseSensitive example
Put "COUPON13995a" into Coupon
MoveTo (Text: Coupon, CaseSensitive:Yes)
Contrast
Type: Boolean
. Whether or not the SUT display is converted to a high contrast two-color image before it is sent to OCR for analysis. If contrast
is on, a color referred to as the "contrast color" which can be set using the ContrastColor
property is considered the primary color of the SUT display, and all other colors are treated as the secondary color. Text can be found in either color. The Contrast
property is available for use with both searching for (finding) text and reading text.
Contrast Example
-- Contrast example
log ReadText(contrast:on, contrastColor:"ffffff", validCharacters: "abcdABCD12345", searchRectangle:("TLImage","BRImage"))
If Contrast
is on, but the ContrastColor
is not defined, the top left pixel of the area being searched is treated as the contrast color.
ContrastColor
A color. Default: The top left corner of the search rectangle is used as the contrast color if Contrast is on and no other color is defined
. If Contrast
is on, the contrast color is considered the primary color of the SUT display, and all other colors are treated as the secondary color. For instructions on finding the background color, see Determining the Background Color. A number of color value formats are recognized by SenseTalk. For the full list of formats, see Color Values in SenseTalk.
ContrastColor Example
-- ContrastColor example
log ReadText(contrast:on, contrastColor:"ffffff", validCharacters: "abcdABCD12345")
ContrastTolerance
Type: Integer, Default: 45
. When Contrast
is on, contrastTolerance
sets the maximum per-channel color difference that is allowed for a pixel to be seen as the contrast color.
ContrastTolerance Example
-- ContrastTolerance example
Click (Text:"Andrew Young", Contrast:On, ContrastTolerance: 65)
DPI
Integer. Default: 72
. The DPI
property refers to the DPI (dots per inch) of the SUT display. If you are having problems finding text on the SUT, check the SUT's DPI setting, and adjust the DPI
property accordingly. Typical DPI settings include: 72, 144, 300, and 2540.
DPI Example
-- DPI example
Click (text: "Continue", DPI: 2540, Language: English)
EnhanceLocalContrast
Type: Boolean. Default: off
. Enable this property if you want OCR to automatically increase the local contrast of the text image being sent to the OCR engine. This property may aid recognition when some or all of the text being read has relatively low contrast, such as blue text on a dark background. When Contrast is turned on, this property has no effect, so it is only useful when Contrast
is turned off.
EnhanceLocalContrast Example
-- EnhanceLocalContrast example
Log ReadText(("TLImage","BRImage"), enhanceLocalContrast: On)
ExtraWords
A word or list of words.
Set this property to a list of words to supplement the built-in dictionary for the current language. These words will be given preference the same way as other dictionary words.ExtraWords
is mutually exclusive with PreferredWords
, ValidPattern
, PreferredPattern
, and ValidWords
.
ExtraWords Example
-- ExtraWords example
Log Readtext(("TLImage","BRImage"), Language: English, ExtraWords: "Elizabeth, Andrew, Steven, Katherine, Jacob, Brenda")
IgnoreNewlines
Type: Boolean
. When enabled, ignoreNewlines
causes OCR text searches to ignore line breaks, so a search will match a string even if it's broken over several lines. This property is only available for text searches (not available with ReadText
). The IgnoreNewlines
property is disabled (off) by default.
IgnoreNewlines Example
-- IgnoreNewLines example
-- In the case of a long name like this, it's possible that it could wrap to a second line in the interface of an application under test, but the OCR could still read it with IngoreNewlines enabled.
Click (Text:"Constantine Papadopoulos", IgnoreNewlines:On)