OcrRegion method

Class: OcrRegionPlatform: Selenium 3Language: Java SDK:

Define a region from which Eyes should extract the image.

You can pass, an element, a selector or a region that defines the top left corner . and dimensions of a rectangle on the current page.

For more information see Eyes OCR support .

This feature is experimental. Please note that the functionality and/or API may change.

Syntax


OcrRegion obj = new OcrRegion(element);

OcrRegion obj = new OcrRegion(selector);

OcrRegion obj = new OcrRegion(region);

Parameters

element
Type:WebElement
An element whose bounding rectangle defines the region from which Eyes should extract text.
selector
Type:By
A selector that defined one or more bounding rectangles that define the region(s) from which Eyes should extract text.
region
Type:Region
The top left corner and dimension of the region from which Eyes should extract text.

Return value

Type: OcrRegion
This method returns the object that called it so that it can be used to call other methods supportd by this class in a fluent API style.

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));
}