關(guān)聯(lián)閱讀:
appium新手入門(mén)(2)—— 安裝 Android SDK
appium新手入門(mén)(3)—— 安裝 appium Server
前提條件
當(dāng)你點(diǎn)擊這一章時(shí),說(shuō)明你是打算使用 Python 語(yǔ)言編寫(xiě) appium 自動(dòng)化測(cè)試腳本的。
1、安裝Python 語(yǔ)言, Python的安裝相對(duì)相簡(jiǎn)單得多。
2、Python 編輯器很多,推薦:PyCharm、Atom、Sublime text3等。這幾款都是我常用的。
安裝 python-client
其實(shí),python-client的項(xiàng)目名稱(chēng)叫:Appium-Python-Client。
推薦pip安裝:
運(yùn)行第一個(gè)Appium測(cè)試
第一步,啟動(dòng)Android模擬器。
第二步,啟動(dòng) Appium Server。
點(diǎn)擊右上角三角按鈕,注意Appium的啟動(dòng)日志。
Appium在啟動(dòng)時(shí)默認(rèn)占用本機(jī)的4723端口,即:127.0.0.1:4723
第三步,編寫(xiě) appnium 測(cè)試腳本。
12
#coding=utf-8
from appium import webdriver
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['appPackage'] = 'com.android.calculator2'
desired_caps['appActivity'] = '.Calculator'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.find_element_by_name("1").click()
driver.find_element_by_name("5").click()
driver.find_element_by_name("9").click()
driver.find_element_by_name("delete").click()
driver.find_element_by_name("9").click()
driver.find_element_by_name("5").click()
driver.find_element_by_name("+").click()
driver.find_element_by_name("6").click()
driver.find_element_by_name("=").click()
driver.quit()
運(yùn)行上面的腳本,你將會(huì)看到 Android 模擬器如下運(yùn)行界面: