Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get x,y coordinates of android native app using selenium

How to get x,y coordinates of android native app using selenium java web driver.

I am using appium. My app opens the android image gallery. As the uiautomatorviewer doesn't show the layout for it. I couldn't able to click an image.

Looks like moveToElement, mouseMoveAt etc is working only for browsers. What are the options available for native app.

like image 318
Tony Avatar asked Nov 24 '25 06:11

Tony


1 Answers

I found a solution by using the below code. By tapping in a certain position I could able to pick an image.

        HashMap<String, Integer> tapObject = new HashMap<String, Integer>();

        tapObject.put("x", 100); // in pixels from left

        tapObject.put("y", 300); // in pixels from top

        driver.executeScript("mobile: tap", tapObject);
like image 79
Tony Avatar answered Nov 25 '25 18:11

Tony



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!