Android变量longpress,Appium+Python Flick longpress press区别(Android)

在使用Appium的Python client端的写Android脚本时,发现使用flick方法输出滑动不好控制,明明是偏移量100px但是有时候滑动很快直接到底部,有时又是100px的距离。所以这样导致我们在写滑动时候很难控制滑动精确位置。经测试发现是Appium Python client端一个Bug导致。 我们通过将flick方法中press修改为longpress解决这个问题

Appium Python client API

def flick(self, start_x, start_y, end_x, end_y):

"""

Flick from one point to another point.

:Args:

- start_x - x-coordinate at which to start

- start_y - y-coordinate at which to start

- end_x - x-coordinate at which to stop

- end_y - y-coordinate at which to stop

:Usage:

driver.flick(100, 100, 100, 400)

"""

action = TouchAction(self)

action \

.press(x=start_x, y=start_y) \

.move_to(x=end_x, y=end_y) \

.release()

action.perform()

return self

上文中使用的press

moveto 中 endx,endy 是相对startx,start_y的偏移量 并存在随机滑动加速度或缓冲滑动

TouchAction(driver) .press({x: 532, y: 1278}) .moveTo({x: 12: y: -371}) .release()

修改后 Appium Python client API

def flick(self, start_x, start_y, end_x, end_y):

"""

Flick from one point to another point.

:Args:

- start_x - x-coordinate at which to start

- start_y - y-coordinate at which to start

- end_x - x-coordinate at which to stop

- end_y - y-coordinate at which to stop

:Usage:

driver.flick(100, 100, 100, 400)

"""

action = TouchAction(self)

action \

.long_press(x=start_x, y=start_y) \

.move_to(x=end_x, y=end_y) \

.release()

action.perform()

return self

上文使用longpress moveto 中 endx,endy 是绝对值 (startx,endx) TouchAction(driver) .press({x: 532, y: 1278}) .moveTo({x: 532: y: 1000}) .release()

其中如有错误,欢迎指正 讨论QQ群:658703911

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值