每天一点:Appium

06:Android屏幕滑动

2017-03-31  本文已影响159人  一直小鱼

滑动,就是一个点移动另一个点。

用法:

    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)
        """

获取手机分辨率

$ width = driver.get_window_size()['width']    #获取宽度
$ height = driver.get_window_size()['height']  #获取高度

屏幕左滑

$  driver.swipe(height/4*3,width/2,height/4,width/2,800)

屏幕右滑

$ driver.swipe(height/4,width/2,height/4*3,width/2,800)

屏幕下滑

$ driver.swipe(height/2,width/4,height/2,width/4*3,800)

屏幕上滑

$ driver.swipe(height/2,width/4*3,height/2,width/4,800)

本文作者原创,禁止转载。

上一篇 下一篇

猜你喜欢

热点阅读