java-client icon indicating copy to clipboard operation
java-client copied to clipboard

Feature: Search for an inner element by an image

Open wazzeps opened this issue 2 years ago • 10 comments

Description

Implement search for an inner element by an image.

Environment

  • java-client: 8.3.0
  • Appium server version: 2.0.0-beta.65
  • Plugin: [email protected]
  • Ubuntu 20.04
  • Android
  • Emulator

Details

Currently, searching for an element by image works for a driver object. Searching for an element using the root element object results in the error.

org.openqa.selenium.InvalidSelectorException: Locator Strategy '-image' is not supported for this session

Code To Reproduce Issue

public class MobileIcon extends Widget {

    protected MobileIcon(WebElement element) {
        super(element);
    }

    public Rectangle getRect() {
        return findElement(AppiumBy.image(imageRefB64)).getRect();
    }
}

wazzeps avatar Apr 20 '23 16:04 wazzeps

This feature has been recently merged and is available now in the master branch of the server.

mykola-mokhnach avatar Apr 25 '23 16:04 mykola-mokhnach

@mykola-mokhnach, when can we expect the feature to be released?

wazzeps avatar May 18 '23 19:05 wazzeps

I believe it is available in the most recent server/plugin releases

mykola-mokhnach avatar May 18 '23 19:05 mykola-mokhnach

I'd like to test it but now I'm getting an error when start the server

[debug] [Appium] Error: Cannot find module '@appium/support' [debug] [Appium] Require stack: [debug] [Appium] - /home/wazzeps/.appium/node_modules/@appium/images-plugin/build/lib/constants.js [debug] [Appium] - /home/wazzeps/.appium/node_modules/@appium/images-plugin/build/lib/compare.js [debug] [Appium] - /home/wazzeps/.appium/node_modules/@appium/images-plugin/build/lib/plugin.js [debug] [Appium] - /home/wazzeps/.appium/node_modules/@appium/images-plugin/index.js [debug] [Appium] - /home/wazzeps/.nvm/versions/node/v19.8.1/lib/node_modules/appium/build/lib/extension/extension-config.js [debug] [Appium] - /home/wazzeps/.nvm/versions/node/v19.8.1/lib/node_modules/appium/build/lib/cli/extension-command.js [debug] [Appium] - /home/wazzeps/.nvm/versions/node/v19.8.1/lib/node_modules/appium/build/lib/cli/driver-command.js [debug] [Appium] - /home/wazzeps/.nvm/versions/node/v19.8.1/lib/node_modules/appium/build/lib/cli/extension.js [debug] [Appium] - /home/wazzeps/.nvm/versions/node/v19.8.1/lib/node_modules/appium/build/lib/main.js [debug] [Appium] - /home/wazzeps/.nvm/versions/node/v19.8.1/lib/node_modules/appium/index.js [debug] [Appium] at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1090:15) [debug] [Appium] at Function.Module._load (node:internal/modules/cjs/loader:934:27) [debug] [Appium] at Module.require (node:internal/modules/cjs/loader:1157:19) [debug] [Appium] at require (node:internal/modules/helpers:119:18) [debug] [Appium] at Object. (/home/wazzeps/.appium/node_modules/@appium/images-plugin/lib/constants.js:1:1) [debug] [Appium] at Module._compile (node:internal/modules/cjs/loader:1275:14) [debug] [Appium] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1329:10) [debug] [Appium] at Module.load (node:internal/modules/cjs/loader:1133:32) [debug] [Appium] at Function.Module._load (node:internal/modules/cjs/loader:972:12) [debug] [Appium] at Module.require (node:internal/modules/cjs/loader:1157:19) [debug] [Appium] at require (node:internal/modules/helpers:119:18) [debug] [Appium] at Object. (/home/wazzeps/.appium/node_modules/@appium/images-plugin/lib/compare.js:4:1) [debug] [Appium] at Module._compile (node:internal/modules/cjs/loader:1275:14) [debug] [Appium] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1329:10) [debug] [Appium] at Module.load (node:internal/modules/cjs/loader:1133:32) [debug] [Appium] at Function.Module._load (node:internal/modules/cjs/loader:972:12) [debug] [Appium] at Module.require (node:internal/modules/cjs/loader:1157:19) [debug] [Appium] at require (node:internal/modules/helpers:119:18) [debug] [Appium] at Object. (/home/wazzeps/.appium/node_modules/@appium/images-plugin/lib/plugin.js:6:1) [debug] [Appium] at Module._compile (node:internal/modules/cjs/loader:1275:14) [debug] [Appium] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1329:10) [debug] [Appium] at Module.load (node:internal/modules/cjs/loader:1133:32)

appium 2.0.0-beta.67 [email protected]

Could I have missed something?

wazzeps avatar May 18 '23 22:05 wazzeps

I've created a patch to address that in the above PR

mykola-mokhnach avatar May 19 '23 06:05 mykola-mokhnach

the patch is now included to the recent server version

mykola-mokhnach avatar May 19 '23 17:05 mykola-mokhnach

It still doesn't work. The error is org.openqa.selenium.InvalidSelectorException: Locator Strategy '-image' is not supported for this session. I have tried this: getWrappedElement().findElement(AppiumBy.image(imageSelector))

appium 2.0.0-beta.71 [email protected] [email protected]

YekaterinaRudakova avatar May 25 '23 08:05 YekaterinaRudakova

@mykola-mokhnach could you continue working on the feature?

wazzeps avatar Sep 10 '23 08:09 wazzeps

Hi. I faced with the same error when trying to find element inside other element using image locator strategy. Do you have some advice how to fix it? I use the latest Appium 2.0.1

MikitaKarbanovich avatar Dec 04 '23 16:12 MikitaKarbanovich

@mykola-mokhnach Hi. Could you clarify was it fixed in Appium 2.0.1? Because I see you made some fix steps, but other people and I still have the error when try to find element by image inside other element. Actually I use C# client, but it seems the Appium server issue, not a client.

MikitaKarbanovich avatar Dec 22 '23 15:12 MikitaKarbanovich