针对appium的webdriver执行swipe无效的解决办法


self.driver.swipe(x1,y1,x2,y1,t)

  

当时代码里有如上这么一句,当时源码是这么说的:

# convenience method added to Appium (NOT Selenium 3)
    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)
        """

由于例子里也没有对最后一个参数进行举例说明,所以我一开始使用的参数为2.后来发现代码执行后并没有实现滑动的效果,后来baidu后有人提示说最后一个数字改为100或200.

最终问题解决。最后一个参数的作用应该是在多少毫秒内进行滑动操作。

原文地址:https://www.cnblogs.com/xiaobaichuangtianxia/p/6961546.html