OcrRegion class
Platform: Selenium 3Language: Java SDK:
An object of this type is used to define where OCR text extraction should be done.
You can extract text
from an application window
using OCR by passing one or more OcrRegion objects to the method
Eyes.extractText.
Each such object
defines a region in the applicaiton window .
In addition, you can use the hint method to specify literal text
or a regular expression-like pattern that should match the text found.
The hint helps overcome ambiguities that arise when using OCR.
It can be used, for example, to disinguish between the numeric '0' (zero) character and the alphabetic 'O' character.
For more information see Eyes OCR support .
This feature is experimental. Please note that the functionality and/or API may change.
Import statement
import com.applitools.eyes.locators.OcrRegion;
Example
WebElement logoElement2 = driver.findElement(new By.ByCssSelector("#btn_logo_png"));
List<String> textsFound = eyes.extractText(
(OcrRegion) new OcrRegion(logoElement2),
(OcrRegion) new OcrRegion(new Region(60, 50, 200, 80)).hint("applitools"),
(OcrRegion) new OcrRegion(new By.ByCssSelector("#btn_click_txt")).hint("Click here"),
(OcrRegion) new OcrRegion(new By.ByTagName("body"))
);
for (int i = 0; i < textsFound.size(); i++) {
System.out.printf("%d) found '%s'\n", i, textsFound.get(i));
}
Constructor
- OcrRegion()
- Define a region from which Eyes should extract the image.
- OcrRegion()
- Define a region from which Eyes should extract the image.
Methods
- hint()
- Use this optional method to define the expected text as literal text or as a pattern.
- hint()
- Use this optional method to define the expected text as literal text or as a pattern.
- region()
- Define a sub-region in the target that should be the area searched using OCR.
- region()
- Define a sub region in the target that should be the area searched using OCR.