我用的这个~
获得机器屏幕大小 x,y
def getSize(self):
x = self.driver.get_window_size()['width']
y = self.driver.get_window_size()['height']
return (x, y)
向上滑动
def swipeUp(self, t):
l = self.getSize()
x1 = int(l[0] * 0.5) # x 坐标
y1 = int(l[1] * 0.75) # 起始 y 坐标
y2 = int(l[1] * 0.25) # 终点 y 坐标
self.driver.swipe(x1, y1, x1, y2, t)
向左滑动
def swipeLeft(self, t):
l = self.getSize()
x1 = int(l[0] * 0.75)
y1 = int(l[1] * 0.5)
x2 = int(l[0] * 0.25)
self.driver.swipe(x1, y1, x2, y1, t)
向右滑动
def swipeRight(self, t):
l = self.getSize()
x1 = int(l[0] * 0.25)
y1 = int(l[1] * 0.5)
x2 = int(l[0] * 0.75)
self.driver.swipe(x1, y1, x2, y1, t)
向下滑动
def swipeDown(self, t):
l = self.getSize()
x1 = int(l[0] * 0.5)
y1 = int(l[1] * 0.25)
y2 = int(l[1] * 0.75)
self.driver.swipe(x1, y1, x1, y2, t)