appium 滑动屏幕

#coding=utf-8
from appium import webdriver
import time
desired_caps = {}
desired_caps[‘platformName’] = ‘Android’ # 设备系统
desired_caps[‘platformVersion’] = ‘4.4’ # 设备系统版本
desired_caps[‘deviceName’] = ‘a2a9dedc’ # 设备名称
desired_caps[‘noReset’]=True

driver = webdriver.Remote(‘http://localhost:4723/wd/hub’, desired_caps)
time.sleep(5)
x= driver.get_window_size()[‘width’]
y= driver.get_window_size()[‘height’]
def swipeLeft(t):
driver.swipe(0.75*x, 0.5*y, 0.05*x, 0.5*y,t)

def swipeRight(t):
driver.swipe(0.05*x, 0.5*y, 0.75*x, 0.5*y,t)

def swipeUp(t):
driver.swipe(0.5*x, 0.75*y, 0.5*x, 0.25*y,t)

def swipeDown(t):
driver.swipe(0.5*x, 0.25*y, 0.5*x, 0.75*y,t)

swipeLeft(1000)
time.sleep(2)

driver.install_app(“apk path”)

driver.remove_app(“packageName”)