This is the second 2-part series on OCR integration with Appium.
In this article, we’ll look at general OCR libraries that cab achieve image recognition and how this library integrate with Appium.
AirTest Library
It is a cross-platform UI automated testing framework based on image identification. And it is suitable for games and apps, and the supported platforms are Windows, Android and iOS.
Install airtest via pip:
The module airtest.core.api in Airtest provides a series of cross-platform API for calling, including touch operation touch, drag operation swipe, input text operationtext and other operations.
Integrate with Appium
Start appium and connect to server:
Get scale of resolution and set size for image recognition:
Overwrite findelement function to support image recognition and return ImageElement:
Appium supports both implicit and explicit wait strategies, to make your tests can robustly wait until your reference UI component exist.
So you need to create your own explicit wait strategies to support find_by_image:
Finnally achieve the operations under ImageElement class:
After framework encapsulation, write the test script: