How to get x,y coordinates of android native app u

2019-05-16 11:16发布

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.

2条回答
男人必须洒脱
2楼-- · 2019-05-16 11:56

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);
查看更多
Explosion°爆炸
3楼-- · 2019-05-16 12:00

Consider switching to Appium. Appium ads an extra layer on top of Selenium which can help you to automate native iOS and Android applications.

http://appium.io

查看更多
登录 后发表回答