自动化测试测试自动化_博客已迁移自动化测试

Appium+IOS 操作方法整理

2019-01-09  本文已影响2人  csmijo

最近在处理ios 的ui 自动化,深深被恶心到了。各种找文档,尝试,这里把我遇到的一些坑和找到的验证过的方法分享一下,希望能够帮助到遇到同样问题的同学。

1. 环境变量

  1. appium:1.9.1
  2. Appium-Python-Client: 0.30
  3. selenium: 3.141.0
  4. python: 3.6.4

2. 元素查找方法

提供的常用方法,待补充。。。

3. 元素操作方法

  1. 点击 tap
self.driver.execute_script("mobile: tap", {"x": 100, "y": 100})
  1. 滑动 swipe,scroll

2.1 有两种 scroll 的方式,但是这种方式不能指定滑动的距离,每次默认滑动一屏幕

diretion = up | down | left | right
1. driver.execute_script("mobile: scroll", {"direction":'up'})
2. driver.execute_script("mobile: scroll", [{"direction":'down', 'element': elementXX}])

2.2 dragFromToForDuration

可以指定 element 滑动指定的距离

 size = self.driver.get_window_size()
 width = size.get("width")
 height = size.get("height")
 self.driver.execute_script("mobile: dragFromToForDuration",
                                       {"element": None, "fromX": (width / 2), "fromY": (height / 2),
                                        "toX": (width / 3), "toY": 0,
                                        "duration": 1})
  1. 等待

3.1 等待固定的时间

self.driver.implicitly_wait(5)

4. 遇到的坑

  1. tap,swipe 失败,提示: Original error:Unhandled endpoint
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Unhandled endpoint: /session/0D3525ED-F8FA-4451-ACAA-446E9712BC27/wda/touch/perform -- http://localhost:8100/ with parameters {
    wildcards =     (
        "session/0D3525ED-F8FA-4451-ACAA-446E9712BC27/wda/touch/perform"
    );
}

ios 高版本已经不支持 swipe,tap,flick ,所以执行这些动作是都会出错。


[参考文献]

  1. [已解决][求助] 关于 IOS 的 swipe 操作无效及一些疑问
  2. ios tap方法在1.8.1版本不兼容, Original error:Unhandled endpoint
  3. mobile scroll command is not working in appium 1.5 for iOS application
上一篇下一篇

猜你喜欢

热点阅读