标签:options android col div get dev and otf inf
前面的文章已经介绍了Robotframework+Appium的安装及小试牛刀(For Android)
下面来个简单的实践,话不多说,还以是计算器为例,直接上代码,详情如下:
1 *** Settings *** 2 Library AppiumLibrary 3 4 *** Test Cases *** 5 case1 6 [Documentation] Test open app 7 Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=7.1 deviceName=Kemi appPackage=com.android.calculator2 appActivity=.Calculator 8 9 case2 10 [Documentation] Test addition 11 Click Element com.android.calculator2:id/digit_9 # 点击数字 9 12 Click Element accessibility_id=plus # 点击 + 号 13 Click Element xpath=//android.widget.Button[contains(@text,‘7‘)] # 点击数字 7 14 Click Element android=new UiSelector().description(\"equals\") # 点击 = 号 15 ${actual_text} Get Text com.android.calculator2:id/result # 获取计算结果 16 Page Should Contain Text ${actual_text} # 验证当前界面包含结果 17 sleep 2 # 设置等待2S 18 Click Element com.android.calculator2:id/clr # 点击清除键 19 20 case3 21 [Documentation] Test subtraction 22 Click Element com.android.calculator2:id/digit_8 # 点击数字 8 23 Click Element accessibility_id=minus # 点击 - 号 24 Click Element xpath=//android.widget.Button[contains(@text,‘2‘)] # 点击数字 2 25 Click Element accessibility_id=equals # 点击 = 号 26 Click Element com.android.calculator2:id/clr # 点击清除键 27 28 case4 29 [Documentation] Test close app 30 Click Element accessibility_id=More options # 点击更多选项 31 Click Element xpath=//android.widget.TextView[contains(@text,‘Open source licenses‘)] 32 sleep 5 # 设置等待5S 33 Press Keycode 4 # 模拟返回键 34 Close Application # 关闭当前应用
如上,testApp.robot脚本中包含四个小用例,打开应用/加法测试/减法测试/关闭应用。运行结果截图如下:
在手机上也可以看到代码中描述的用例在自动运行。
更多实践见后续文章~
Python + Robotframework + Appium 之APP自动化测试实践(一)
标签:options android col div get dev and otf inf
原文地址:https://www.cnblogs.com/cnkemi/p/9685487.html