Appium Appium 1.6.3 iOS 怎么写拖着滑的事件

doye · January 17, 2017 · Last by aylin replied at February 23, 2017 · 1412 hits

RT 就是从 A 坐标按下滑到 B 坐标弹起这样

我有个不太清楚的是这里是要先定为控件然后写的坐标是参照对应 element 的坐标系么?

使用 Python 实现,但是主要还是不知道现在支持啥
之前好像是

wd = self.driver
wd.execute_script("mobile: swipe", {"touchCount": 1 , "startX": 294, "startY": 173, "endX": 119, "endY": 177, "duration": 0.5 })
#服务端会报execute_script swipe类型 现在不支持,然后可能之后会支持但想要现在的。。

然后这个

然后搜了下有个 TouchAction 系列

(这里是 python 的文档,而且 press 什么还不给好好写)

action.press(el).move_to(x=10, y=0).move_to(x=10, y=-75).move_to(x=10, y=-600).perform()

# 报 Support for this gesture is not yet implemented. Please contact an Appium dev

然后忘了从哪找了个

wd.swipe(0,100,250,100,500)
#也不行,但是服务器没报错,不知道是不是因为第一个参数不对,我填个element进去也不对。。

Help ~~~~~ 😭

共收到 7 条回复 时间 点赞
doye #1 · January 17, 2017 Author

求教一般 python 模块接口文档哪里看?我看有的有文档有的没有,没文档的总不能翻源码看接口吧 QAQ

doye #2 · January 17, 2017 Author

def swipe(self, start_x, start_y, end_x, end_y, duration=None):
        """Swipe from one point to another point, for an optional duration.
        :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
         - duration - (optional) time to take the swipe, in ms.
        :Usage:
            driver.swipe(100, 100, 100, 400)
        """

这样,但是这个坐标系是相对啥的

TouchAction(self.driver).long_press(origin_el).wait(5000).move_to(destination_el).release().perform()

这里面的 origin_el 和 destination_el 可以换成坐标

需要在 press 后面加个等待时间就好,要不然会出现拖动不成功的情况

doye #5 · January 18, 2017 Author

#4 楼 @cloudwind 应该都可以。。不过 origin_el 这个参数填坐标没跑通(报 Support for this gesture is not yet implemented. Please contact an Appium dev,你是 iOS10+ 还是老框架?)。。不过单纯一个滑动用 swipe(100, 100, 100, 400) 也是可以的。

#1 楼 @doye python 模块接口文档哪里看的问题解决了吗?😂

swipe(15,15,0,-10)表示从(15,15)坐标点往上滑动 10
endx 和 endy 是幅度,而不是坐标。这点是和安卓滑动方法的最大区别

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up