UNPKG

wdio-ocr-service

Version:

A WebdriverIO service that is using Tesseract OCR for Appium Native App tests.

58 lines (54 loc) 1.26 kB
import { Rectangles, ScreenSize } from '../typings/types' import ocrKeys from '../utils/ocrKeys' import ocrClickOnText from './ocrClickOnText' interface OcrSetValueOptions { androidRectangles?: Rectangles; iOSRectangles?: Rectangles; isTesseractAvailable: boolean; language: string; reuseOcr: boolean; ocrImagesPath: string; screenSize: ScreenSize; text: string; value: string; clickDuration?: Number; } export default async function ocrSetValue(options: OcrSetValueOptions): Promise<void> { const { androidRectangles, iOSRectangles, isTesseractAvailable, language, reuseOcr, ocrImagesPath, screenSize, text, value, clickDuration } = options await ocrClickOnText({ androidRectangles, iOSRectangles, isTesseractAvailable, language, ocrImagesPath, reuseOcr, screenSize, text, clickDuration }) await driver.waitUntil( async () => driver.isKeyboardShown(), { timeout: 15000, timeoutMsg: 'Keyboard was not hidden', }) await ocrKeys(value) await driver.hideKeyboard() await driver.waitUntil( async () => !(await driver.isKeyboardShown()), { timeout: 15000, timeoutMsg: 'Keyboard is still shown', }) }