Appium Python Instance script 1

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.