Appium 请教自动化测试工具 python-uiautomator2 捕捉到元素后,如何用 python 脚本实现啊

arsenalley · 2018年06月29日 · 最后由 arsenalley 回复于 2018年06月30日 · 1714 次阅读

请教自动化测试工具 python-uiautomator2 捕捉到元素后,如何用 python 脚本实现啊;
先上图:

如图中已经定位到的元素, 怎么用 python 语言实现呢?
d(className="android.view.View", instance=44)
这种定位现实是用 java 语言实现的吧。

在线等啊,大神们?

——————————————————————
大家好,我再详细说明一下我的情况:
我现在在写关于小程序的自动化脚本,用的 uiautomatorrviewer 工具来定位元素的;
方法就是简单的 self.driver.find_element_by_id(‘定位到的元素’).click 这个方法来进行定位,点击,赋值等等操作
但是有些元素 uiautomatorrviewer 定出不到,或者根本就没有 id,name,class 等属性就不好定位了,
所以就使用 uiautomator2 进行定位
就像 d(className="android.view.View", instance=44) 图中定位的元素,
那我现在用 python,driver 方法怎么去实现呢 ?

共收到 7 条回复 时间 点赞

d(className="android.view.View", instance=44).click()

linpengcheng 回复

你好,请问是如何实现封装的啊?
我还停留在 python 实现点击:
driver.find_elements_by_class_name().click()

arsenalley 回复

https://github.com/openatx/uiautomator2 readme 从头到尾看一遍就差不多了

arsenalley · #4 · 2018年06月29日 Author
僅樓主可見
linpengcheng 回复

您好,我再详细说明一下我的情况:
我现在在写关于小程序的自动化脚本,用的 uiautomatorrviewer 工具来定位元素的;
方法就是简单的 self.driver.find_element_by_id(‘定位到的元素’).click 这个方法来进行定位,点击,赋值等等操作
但是有些元素 uiautomatorrviewer 定出不到,或者根本就没有 id,name,class 等属性就不好定位了,
所以就使用 uiautomator2 进行定位
就像 d(className="android.view.View", instance=44) 图中定位的元素,
那我现在用 python,driver 方法怎么去实现呢 ?

你是想说用 appium 怎么实现的吧

codeskyblue 回复

是的

需要 登录 後方可回應,如果你還沒有帳號按這裡 注册