New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Appium image locator strategy fails for the simplest images. #6097
Comments
Hi @Rup1 I've tested it and it works on my machine (typical reaction 😆 ) TL:DRThe image that you use can not be matched because the screenshot that is being used to find the image has automatically been resized by Appium. This can be solved by updating the Appium server with the settings API, see here Detailed explanationWhat happens with Appium is the following:
If you created an element screenshot based on the original screenshot where the DPR was bigger than 1 and you compare that with the resized screenshot by Appium it will never find it. This is from my Appium logs
Now think what will happen when the original screenshot is resized from 828x1792 to 414x896, then you will never be able to find the element Original screenshot But when you adjust the server settings with this, before you run the image selection it will work, see also the new logs with explained steps browser.updateSettings({
// See https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/image-elements.md#related-settings
fixImageTemplateScale: true,
});
I've tested it with this script on my local machine describe('Find by Image', () => {
it('should be able to find and element and click on it', () => {
browser.updateSettings({
// See https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/image-elements.md#related-settings
fixImageTemplateScale: true,
});
// For demo purpose
browser.pause(5000);
// Click on the image
$('image.png').click();
// For demo purpose
browser.pause(5000);
});
}); |
@wswebcreation Wow that was quick! Really great explanation thank you so much for the details. I was able to update accordingly and get it to work. It would help many others if this explanation were included in the docs, which currently lack practical javascript examples. Cheers |
Environment (please complete the following information):
Config of WebdriverIO
Describe the bug
Hard to tell if this is an Appium or wdio issue. Wdio is unable to find the number "1" on macos calculator using an image file, returns
'no such element'
error even though element is on the screen and represents a very basic image:calculator:
I've tried a bunch of different images, and initially tried on ios. Never works, and I havent' found any working examples online.
To Reproduce
clone the following repository, run
npm i
and then runnode macOsCalculator
.You need to have
opencv4nodejs
installed on your machine for image search to work.https://github.com/Rup1/appium-findbyimage
Expected behavior
I expect wdio to easily find the simple image and click the element.
Log
Appium log:
https://gist.github.com/Rup1/2e25a51b26483beb894351cddebeb6d8
The text was updated successfully, but these errors were encountered: