您现在的位置是:首页 > 文章详情

APPium+Python+iOS使用execute_script() 屏幕滑动方法对比

日期:2018-11-15点击:543

最近在学习appium自动化,对iOS手机进行滑动操作进行总结:
1、mobile:scroll
向下滚动整个屏幕
driver.execute_script('mobile: scroll', {'direction': 'down'})
向上滚动整个屏幕
driver.execute_script('mobile: scroll', {'direction': 'up'})
向左滚动整个屏幕
driver.execute_script('mobile: scroll', {'direction': 'left'})
向右滚动整个屏幕
driver.execute_script('mobile: scroll', {'direction': 'right'})
该方法在实际使用调用时,会滚动2次。执行时间很长。

2、mobile:swipe
向下滚动屏幕
driver.execute_script('mobile: scroll', {'direction': 'up'})
向上滚动屏幕
driver.execute_script('mobile: scroll', {'direction': 'down'})
向右滚动屏幕
driver.execute_script('mobile: scroll', {'direction': 'left'})
向左滚动屏幕
driver.execute_script('mobile: scroll', {'direction': 'right'})
该方法在调用过程中,执行速度快,滑动屏幕距离短

3、mobile:dragFromToForDuration
duration: 浮点数范围[0.5,60]。表示开始拖动点之前的点击手势需要多长时间才能开始拖动
fromX:起点X坐标
fromY:起点Y坐标
toX:终点X坐标
toY:终点Y坐标
以上都是必要参数。
element:控件ID,可以指定为None,为None时以整个手机屏幕为边界。
示例:
driver.execute_script("mobile:dragFromToForDuration",{"duration":0.5,"element":None,"fromX":0,"fromY":650,"toX":0,"toY":100}
该方法在调用过程中,执行速度快,滑动屏幕距离可根据屏幕进行控制,但是如果滑动中起点坐标在控件上,会触发点击操作。

原文链接:https://yq.aliyun.com/articles/670123
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章