新手区 Appium 1.6.3 版本编写的脚本如何兼容 ios9.3 以下的 ios 设备执行?

bauul · 2017年02月15日 · 最后由 songz 回复于 2017年02月16日 · 1448 次阅读

事由

Appium 1.6.3 版本获取的控件树含很多的 other 这样的 element,导致生成的 xpath 与 Appium 1.4.13 版本生成的 xpath 相差太多,不能兼容。

同一个控件的 xpath:
1.6.3: //XCUIElementTypeApplication[1]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeButton[2]
1.4.13:
//UIAApplication[1]/UIAWindow[1]/UIAButton[3]

提问

大家是怎么做的?可以做到完全互相兼容吗?

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 8 条回复 时间 点赞

@seveniruby @xiaoli @chenhengjie123
请教哥哥姐姐们👀

不要用 xpath 不行嘛。。。xpath 原理上决定了很难兼容。因为 iOS 10 上 WebDriverAgent 识别元素的方式和 iOS 10 以下的 UIAutomation 区别很大,包括元素标签名这些都有差别。

#2 楼 @chenhengjie123
你说的也对

#2 楼 @chenhengjie123 也可以用 把 xpath 优化下 不要用//xxx 用//*[...] 风格

#4 楼 @seveniruby
//*[...] 使用这个的时候需要加上限制条件,我说的限制条件是比如不能点击 other 这种控件,它是没 name, label 等属性的。

手动加 accessbility 属性

#6 楼 @neyo
大哥,可以举个例子吗?没加过,不知道如何操作。感谢

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册