#coding=utf-8
import os, time, unittest
from appium import webdriver
PATH = lambda p:os.path.abspath(os.path.join(os.path.dirname(__file__),p))
desired_caps = {}
desired_caps['platformName'] = 'Android' # 设备系统
desired_caps['platformVersion'] = '4.3' # 设备系统版本
desired_caps['deviceName'] = '3230df4ba1c6cfd3' # 设备名称
desired_caps['app'] = PATH(r"/Users/xxx/Downloads/xxx.apk")
desired_caps['appPackage'] = 'com.cn.xxx'
desired_caps['appActivity'] = 'com.cn.xxx.activity.splash.SplashActivity'
driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
#休眠10s等待程序启动
time.sleep(10)
print ("aaaaaaa")
#获取页面长宽
def getSize():
x = driver.get_window_size()['width']
y = driver.get_window_size()['height']
return (x, y)
#屏幕向左滑动
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)
#调用向左滑动
swipLeft(1000)
time.sleep(5)
#调用向左滑动
swipLeft(1000)
#调用向左滑动
time.sleep(5)
swipLeft(1000)
time.sleep(5)
driver.find_element_by_id('com.cn.xxx:id/tv_go').click()
time.sleep(5)
driver.find_element_by_id('com.cn.xxx:id/btn_continue').click()
time.sleep(5)
driver.find_element_by_id('com.cn.xxx:id/btn_move').click()