#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 ' # device system
desired_caps[' platformversion ' = ' 4.3 ' # device system version
desired_caps[' devicename ' = ' 3230df4ba1c6cfd3 ' # device name
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 ()
Appium Python Instance script 1