Skip to main content

ocrWaitForTextDisplayed

Wait for a specific text to be displayed on the screen.

Usage#

driver.ocrWaitForTextDisplayed('Username')

Options#

NameTypeDefaultDetails
selectorstringThe text you want to wait for (mandatory)
options (optional)WaitForTextDisplayed{}command options
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
options.timeout (optional)number180000Time in ms. Be aware that the OCR process can take some time, so don't set it too low.
options.timeoutMsg (optional)stringCould not find the text "{selector}" within the requested time.If exists it overrides the default error message

Example#

it('should detect when text is shown on the screen', () => {
driver.ocrWaitForTextDisplayed('Username')
// Wait with options
driver.ocrWaitForTextDisplayed(
'Username',
{
// Same as for iOSRectangles
androidRectangles: {
top: 200,
left: 0,
right: 800,
bottom: 400,
},
timeout: 45000,
},
)
})