測試軟件:appium api demos # 可在github appium 項(xiàng)目內(nèi)下載
使用設(shè)備:安卓模擬器
-
準(zhǔn)備工作:
-
下載 appium-uiautomator2-driver
cnpm install appium-uiautomator2-driver
-
capability內(nèi)新增:automationName
-
簡介:使用哪種自動(dòng)化引擎
Appium(默認(rèn))或Selendroid或UiAutomator2或Espresson用于Android或XCUITestiOS或YouiEngine用于使用You.i Engine構(gòu)建的應(yīng)用程序
-
-
appium 版本:1.13.0
-
目標(biāo)toast
- 路徑:Api Demos → Views → Popup Menu → MAKE A POPUP!
-
代碼如下
import time from appium import webdriver desired_caps = {} desired_caps['platformName'] = 'Android' desired_caps['platformVersion'] = '5.1.1' desired_caps['deviceName'] = '127.0.0.1:62001' desired_caps['appPackage'] = 'io.appium.android.apis' desired_caps['appActivity'] = 'io.appium.android.apis.ApiDemos' desired_caps['noReset'] = "False" desired_caps['automationName'] = "uiautomator2" driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) driver.find_element_by_android_uiautomator( 'new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text' f'("Views").instance(0));').click() driver.find_element_by_android_uiautomator( 'new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text' f'("Popup Menu").instance(0));').click() driver.find_element_by_xpath('//android.widget.Button[@content-desc="Make a Popup!"]').click() time.sleep(1) driver.find_element_by_xpath("http://*[@text= 'Search']").click() time.sleep(1) print(driver.find_element_by_xpath("http://*[@class='android.widget.Toast']").text)
-
測試結(jié)果
-
運(yùn)行過程
Words
Appium、appium + android橱乱、toast識別臣嚣、獲取toast信息盈罐、uiautomator2、appium-uiautomator2-driver
Blog:
- 簡書:http://www.reibang.com/u/ec81abf35751
- CSDN:https://blog.csdn.net/qq_21238607
- 微信公眾號:rzbbzr