Skip to main content

ocrGetText

Get the text on an image.

Usage#

driver.ocrGetText()

Options#

NameTypeDefaultDetails
options (optional)GetTextOptions{}command options
options.reuseOcr (optional)booleanfalseRe-use a previous OCR scan if it is available
options.androidRectangles (optional)RectanglesRectangles for Android to crop the search area for OCR
options.androidRectangles.topnumberStart position from the top of the screen to start cropping the search area for OCR
options.androidRectangles.leftnumberStart position from the left of the screen to start cropping the search area for OCR
options.androidRectangles.rightnumberStart position from the right of the screen to start cropping the search area for OCR
options.androidRectangles.bottomnumberStart position from the bottom of the screen to start cropping the search area for OCR
options.iOSRectangles (optional)RectanglesRectangles for Android to crop the search area for OCR
options.iOSRectangles.topnumberStart position from the top of the screen to start cropping the search area for OCR
options.iOSRectangles.leftnumberStart position from the left of the screen to start cropping the search area for OCR
options.iOSRectangles.rightnumberStart position from the right of the screen to start cropping the search area for OCR
options.iOSRectangles.bottomnumberStart position from the bottom of the screen to start cropping the search area for OCR

Returns#

Returns the text on the screen

Example#

it('should be able to the the text of a screen', () => {
// Assert that the word `PRODUCTS` is shown
expect(driver.ocrGetText()).toContain('PRODUCTS')
// OR assert with options
expect(driver.ocrGetText(
{
// Same as for iOSRectangles
androidRectangles: {
top: 200,
left: 0,
right: 800,
bottom: 400,
},
reuseOcr:true,
}
)).toContain('PRODUCTS')
})