iOS自动化使用appium关于gesture的更新
最近几天在修改ruby的自动化测试框架,需要加上appium的相关支持。
于是参照了自己以前在python自动化框架中实现的部分,但是发现TouchAction无法执行,Tap或者swipe等均不生效,提示“unknown server-side error occurred while processing the command”。一度怀疑是测试环境出了问题。多次调试后未成功,去搜索了官方资料,发现iOS的手势操作有些变化。
参照下面官方链接的说明:
Unfortunately Apple's XCTest framework does not natively support W3C standards for TouchAction interface implementation. Although, it provides rich set of gestures, inluding these, that are unique for iOS platform. It is possible to directly invoke these gestures in Appium starting from version 1.6.4-beta.
It is important to rememeber that XCTest and WDA are being constantly changed. This means all "mobile: *" commands can be also subject of change in Appium without any preliminary notice.
将操作替换为类似下面的语句则可以成功操作手势,使用更简洁方便。
@driver.execute_script 'mobile: tap', :x => 200, :y => 10, :fingers => 1, :tapCount => 1, :duration => 0.5, :element => login_button.ref