Issue
I am testing demo apk app provided by appium , in which I am testing Reverse Animation. On clicking "Play" and "Reverse" button , the ball goes up and down. Is it possible to check , if the ball has reached a certain coordinate. The ball has no locator as such
Solution
There is a feature in Appium to find elements by image. There is an article written for this on the Appium Pro platform: https://appiumpro.com/editions/32-finding-elements-by-image-part-1.
Create image: It accepts a base64 image to search for an element, you can do this by making an image of the ball and put it in the main/resources folder. With the correct method you can create the base64:
private String getReferenceImageB64() throws URISyntaxException, IOException {
URL refImgUrl = getClass().getClassLoader().getResource("Edition031_Reference_Image.png");
File refImgFile = Paths.get(refImgUrl.toURI()).toFile();
return Base64.getEncoder().encodeToString(Files.readAllBytes(refImgFile.toPath()));
}
getLocation(): Once it successfully found the image and you can steer the element, you may use the .getLocation() method. This is described on the documentation: http://appium.io/docs/en/advanced-concepts/image-elements/.
Answered By - kenneth
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.