appium2.0 + appium-python-client + swipe

def swipe(self, start_x: int, start_y: int, end_x: int, end_y: int, duration: int = 0) -> 'WebDriver':
    """从一个点滑动到另一个点,可选择设置持续时间

    参数:
    start_x: 开始滑动的 x 坐标
    start_y: 开始滑动的 y 坐标
    end_x: 结束滑动的 x 坐标
    end_y: 结束滑动的 y 坐标
    duration: 定义滑动速度,即从点 a 滑动到点 b 所需的时间,单位为毫秒。

    用法:
        driver.swipe(100, 100, 100, 400)

    返回:
        Union['WebDriver', 'ActionHelpers']: 返回自身实例
    """
    touch_input = PointerInput(interaction.POINTER_TOUCH, 'touch')

    actions = ActionChains(self.driver)
    actions.w3c_actions = ActionBuilder(self.driver, mouse=touch_input)
    actions.w3c_actions.pointer_action.move_to_location(start_x, start_y)
    actions.w3c_actions.pointer_action.pointer_down()
    if duration > 0:
        actions.w3c_actions = ActionBuilder(self.driver, mouse=touch_input, duration=duration)
    actions.w3c_actions.pointer_action.move_to_location(end_x, end_y)
    actions.w3c_actions.pointer_action.release()
    actions.perform()
    return cast('WebDriver', self)
  • 11
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值