標籤:手機 ima ges start cas 測試架構 robot orm ppp
Click Element關鍵字用來類比點擊APP介面上的一個元素,該關鍵字接收一個參數[ locator ] ,這裡的locator指的是介面元素的定位方式。
樣本1:使用Click Element關鍵字來類比點擊一個button按鈕,這裡locator使用name的方式來定位需要點擊的元素,依舊採用上面之前使用過的APP介面來做操作樣本。
Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=22 deviceName=98YFBP522VSU app=C:/Users/yongqing/Desktop/app-debug.apk appPackage=com.example.calculator appActivity=MainActivity
Input Text accessibility_id=輸入框 23
Input Text id=com.example.calculator:id/factortwo 12
Click Element name=計算
執行結果:
Starting test: RobotFrameworkTest1.TestSuite5.TestCase007
20170510 15:13:18.868 : INFO : Typing text ‘23‘ into text field ‘accessibility_id=輸入框‘
20170510 15:13:18.868 : INFO : msg:find accessibility_id=輸入框
20170510 15:13:25.718 : INFO : msg:find id=com.example.calculator:id/factortwo
20170510 15:13:31.077 : INFO : Clicking element ‘name=計算‘.
20170510 15:13:31.077 : INFO : msg:find name=計算
20170510 15:13:31.704 : INFO : elements: [<appium.webdriver.webelement.WebElement (session="3b92f067-4ddd-4dc5-90eb-c6915eb8e364", element="3")>]
Ending test: RobotFrameworkTest1.TestSuite5.TestCase007
從執行結果可以看到,通過Click Element關鍵字也可以類比點擊一個button按鈕。
RobotFramework自動化測試架構-移動手機自動化測試Click Element關鍵字的使用