APP上下左右滑動螢幕的處理
#獲得機器螢幕大小x,y
driver = self.driver
def getSize():
x = driver.get_window_size()['width']
y = driver.get_window_size()['height']
return (x, y)
#螢幕向上滑動
def swipeUp(t):
l = getSize()
x1 = int(l[0] * 0.5) #x座標
y1 = int(l[1] * 0.75) #起始y座標
y2 = int(l[1] * 0.25) #終點y座標
driver.swipe(x1, y1, x1, y2,t)
#螢幕向下滑動
def swipeDown(t):
l = getSize()
x1 = int(l[0] * 0.5) #x座標
y1 = int(l[1] * 0.25) #起始y座標
y2 = int(l[1] * 0.75) #終點y座標
driver.swipe(x1, y1, x1, y2,t)
#螢幕向左滑動
def swipLeft(t):
l=getSize()
x1=int(l[0]*0.75)
y1=int(l[1]*0.5)
x2=int(l[0]*0.05)
driver.swipe(x1,y1,x2,y1,t)
#螢幕向右滑動
def swipRight(t):
l=getSize()
x1=int(l[0]*0.05)
y1=int(l[1]*0.5)
x2=int(l[0]*0.75)
driver.swipe(x1,y1,x2,y1,t)
#呼叫向左滑動
swipLeft(1000)
sleep(3)
#呼叫向右滑動
swipRight(1000)
呼叫向上滑動
swipeUp(1000)
呼叫向下滑動
swipeDown(1000)
將要呼叫的程式碼放入登入指令碼內,即可呼叫