#coding=utf-8
from appium import webdriver
from time import sleep
import os
from selenium.webdriver.common.by import By
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
desired_caps = {
'platformName':'Android',
'platformVersion':'4.4.2',
'deviceName':'Y15QKCNQ237LC',
# desired_caps['app'] =PATH('C:\Users\Administrator\Desktop\shoujitaobao_151.apk')
#如果手机未安装该软件,且安装包在电脑上,则需指定路径,包名和活动名可不指定
#如果手机已经安装,则不需指定路径,指定下面的包名和活动名即可
'appPackage':'com.taobao.taobao',
'appActivity':'com.taobao.tao.welcome.Welcome',
#屏蔽软键盘,方便输入中文
'unicodeKeyboard':True ,
'resetKeyboard':True
}
#启动app
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
sleep(5)
y = driver.get_window_size()['height']
print y
#屏幕上滑
driver.swipe(0, int(y) * 0.75, 0, int(y) * 0.25)
#屏幕下滑
driver.swipe(0, int(y) * 0.25, 0, int(y) * 0.75)