Appium Image Recognition
Appium supports Image Locator Strategy, which relies on the OpenCV library.
We created a special Appium OSS image (1.22.2.cv) that is based on Appium 1.22.2 version with the support of the opencv4nodejs library.
With this plugin, you can find elements Native or Web by the image locator, as well as compare and find similarity between images.
For more information see Image Elements and Image Comparison.
Usage Examples
Gradle Dependency
implementation 'io.appium:java-client:8.3.0'
Example Code for io.appium.java_client:8.3.0
File img = new File(filePath);
String base64EncodedImageFile = Base64.getEncoder().encodeToString(Files.readAllBytes(img.toPath()));
By imageLocator = AppiumBy.image(base64EncodedImageFile);
WebElement element = driver.findElement(imageLocator);
element.click();
Install the Appium Image
- From the machine of docker swarm open a terminal and run:
docker pull public.ecr.aws/dai-ct/appium-opensource:1.22.2.cv-6
- Open the Docker's Portainer and make sure the image is there (instructions are here.