Appium ios appium swipe 滑动

troubl_2014 · 2023年05月11日 · 2842 次阅读

IOS 滑动比较
对 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:dragFromToForDurationduration: 浮点数范围 [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})该方法在调用过程中,执行速度快,滑动屏幕距离可根据屏幕进行控制,但是如果滑动中起点坐标在控件上,会触发点击操作。
如:部分上滑 self.driver.execute_script("mobile:dragFromToForDuration",
{"duration": 0.5, "element": None, "fromX": self.width * 0.5,
"fromY": self.height * from_y, "toX": self.width * 0.5,
"toY": self.height * to_y})

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