Search for multiple elements with the same image

Hello, I ran into the problem of finding elements on a page using the image search method.
When using the findElementByImage method, the appium finds only one element that matches the provided template, even if there are several such elements on the page. I need to find all these elements that are similar to each other. To do this, I used the findElementsByImage method, which searches for all the same elements on the page and enters them into a List. But for some reason this method does not work for me. When using the findElementsByImage method, only one first element is determined anyway, ending at this search, all other elements of the same with the same image are disregarded. How can you find a solution to this problem?

My method for find this elements:

public ImageSelector findAllViolations() throws IOException {
        driver.setSetting(Setting.IMAGE_MATCH_THRESHOLD, 0.68);
        List<MobileElement> elementsOne = driver.findElementsByImage(findViolation());
        for (MobileElement violation : elementsOne) {
  "Count images: "+elementsOne.size());

        saveScreenshot(((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES));"Violation found!");
        return this;
    } was supposed to fix that but it never got finished by its author

In this case, what advice would you give when trying to search for multiple images?

The author got time to finish his PR. The patch has been published to appium@beta

1 Like

Thank you very much for the answer.
I wanted to apologize, but I could not find the beta patch in the appium branch. Is it in the appium, or in the appium driver?

you could install beta from CLI: npm i -g appium@beta

1 Like

It works! Thank you for your timely responses and help.
But sometimes (maybe in 80% cases) i get error when running tests -
org.openqa.selenium.WebDriverException: org.openqa.selenium.NoSuchSessionException: A session is either terminated or not started
She started to appear after the appium update. Maybe u have solution about this problem?

I cannot help nothing without the logs/detailed issue description. Make sure you properly close all your sessions before starting new ones

I apologize for my stupidity.
It’s my console when that happened.
I also have the parameter setCapability(“newCommandTimeout”, “0”);
If I downgrade the appium version the problem goes away.