Page tree
Skip to end of metadata
Go to start of metadata

Appium supports Image Locator Strategy , which relies on 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 the help of this plugin ,we can find elements Native or Web by the image locator.

Also compare and find similarity between images.

You can read more about it , and the use of different flags from appium documentation and Appium Image Comparison documentation.


Example:

findElementByImage
File img = new File("LOCAL_PATH_TO_THE_IMAGE");
String base64EncodedImageFile = Base64.getEncoder().encodeToString(Files.readAllBytes(img.toPath()));
By imageLocator = MobileBy.image(base64EncodedImageFile); 
WebElement element = driver.findElementByImage(base64EncodedImageFile); // or use the locator driver.findElement(imageLocator);
assertTrue(element.isDisplayed());
element.click();

Instructions to install the appium image

  1. Downloading the installation script:

    1. For Appium 1.22.2 version with openCV library: 

curl -L https://experitest-appium.s3.amazonaws.com/customer-download-opencv.sh -o customer-download-opencv.sh

b. Run the sh script:

$ sh customer-download-opencv.sh “<DOCKER SERVER 1 IP>,<DOCKER SERVER 2 IP>”


  • No labels