appium python執行個體指令碼1

來源:互聯網
上載者:User

標籤:remote   orm   from   swipe   gets   idt   file   users   utf-8   

#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()

appium python執行個體指令碼1

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.