如何使用 selenium 获取 android 本机应用程序的 x,y 坐标 [英] How to get x,y coordinates of android native app using selenium
问题描述
如何使用 selenium java web 驱动程序获取 android 本机应用程序的 x,y 坐标.
How to get x,y coordinates of android native app using selenium java web driver.
我正在使用 appium.我的应用程序打开了 android 图片库.由于 uiautomatorviewer 没有显示它的布局.我无法点击图片.
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.
看起来像 moveToElement、mouseMoveAt 等仅适用于浏览器.本机应用程序有哪些可用选项.
Looks like moveToElement, mouseMoveAt etc is working only for browsers. What are the options available for native app.
推荐答案
我使用以下代码找到了解决方案.通过点击某个位置,我可以选择图像.
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);
这篇关于如何使用 selenium 获取 android 本机应用程序的 x,y 坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!