Robot Framework+Appium案例分享一: 验证版本信息
来源:互联网 发布:手机淘宝品牌怎么填 编辑:程序博客网 时间:2024/06/17 15:27
在之前的博客“Robot Framework + Appium测试Android设备”,我们已经介绍了如何使用Robot Framework和Appium测试Android设备,如果对这部分还不熟悉的童鞋,可以参考本人之前的博客。
本文分享2个测试suit, 一个是抓取并验证Android的版本信息; 另一个是抓取battery的版本信息.
测试suit 1, 抓取并验证Android的版本信息.
测试步骤,
1. 打开Setting App;
2. 进入About页面;
3. 验证版本信息
3.1 Test Case 1: 验证Build Number
3.2 Test Case 2: 验证Android Version
3.3 Test Case 3: 验证Model Number
示例代码如下,
*** Settings ***Suite Setup Open Settings AppSuite Teardown Close ApplicationLibrary AppiumLibrary*** Variables ***${EXPECTED_BUILD_NUMBER} Build_Number_xxx${EXPECTED_ANDROID_VERSION} 6.0.1${EXPECTED_MODEL_NUMBER} Model_Number_xxx*** Test Cases ***Test Case 1: Build Number Test [Tags] System Information Verify Build Number ${EXPECTED_BUILD_NUMBER}Test Case 2: Android Version Test [Tags] System Information Verify Android Version ${EXPECTED_ANDROID_VERSION}Test Case 3: Model Number Test [Tags] System Information Verify Model Number ${EXPECTED_MODEL_NUMBER}*** Keywords ***Open Settings App Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=6.0.1 deviceName=dev_name appPackage=com.android.settings appActivity=.Settings Sleep 2s Open About phone pageOpen About phone page Log Step 1: Scroll down until find "About phone" : FOR ${i} IN RANGE 20 \ Swipe 400 1000 400 500 200 \ ${count} Get Matching Xpath Count xpath=//*[contains(@text, 'About phone')] \ Exit For Loop If ${count}>0 Log Step 2: Click the "About Phone" Label Click Element xpath=//*[contains(@text, 'About phone')] Log Step 3: Scroll down until find "Build number" : FOR ${i} IN RANGE 20 \ Swipe 400 1000 400 500 200 \ ${count} Get Matching Xpath Count xpath=//*[contains(@text, 'Build number')] \ Exit For Loop If ${count}>0Verify Build Number [Arguments] ${expected_build_number} Log Verify the Page if contains the right build number Page Should Contain Text ${expected_build_number} INFOVerify Android Version [Arguments] ${expected_android_version} Log Verify the Page if contains the right Android Version Page Should Contain Text ${expected_android_version} INFOVerify Model Number [Arguments] ${expected_Model_Number} Log Verify the Page if contains the right model number Page Should Contain Text ${expected_Model_Number} INFO
1. 打开Setting App;
2. 进入About phone页面;
3. 进入Battery Information页面;
4. 验证版本信息
4.1 Test Case 1: 验证Battery Part Number
4.2 Test Case 2: 验证Battery Serial Number
示例代码如下,
*** Settings ***Suite Setup Open Settings AppSuite Teardown Close ApplicationLibrary AppiumLibrary*** Variables ***${EXPECTED_BATTERY_PART_NUMBER} PartNumber_xxx${EXPECTED_BATTERY_SERIAL_NUMBER} A4753*** Test Cases ***Test Case 1: Battery Part Number Test [Tags] Battery Management Verify Battery Part Number ${EXPECTED_BATTERY_PART_NUMBER}Test Case 2: Battery Serial Number Test [Tags] Battery Management Verify Battery Serial Number ${EXPECTED_BATTERY_SERIAL_NUMBER}*** Keywords ***Open Settings App Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=6.0.1 deviceName=dev_name appPackage=com.android.settings appActivity=.Settings Sleep 4s Open Battery Information pageOpen Battery Information page Log Step 1: Scroll down until find "About phone" : FOR ${i} IN RANGE 20 \ Swipe 400 1000 400 500 200 \ ${count} Get Matching Xpath Count xpath=//*[contains(@text, 'About phone')] \ Exit For Loop If ${count}>0 #Scroll Down xpath=//*[contains(@text, 'Display')] Log Step 2: Click the "About Phone" Label Click Element xpath=//*[contains(@text, 'About phone')] Log Step 3: Click the "Battery Information" Label Click Element xpath=//*[contains(@text, 'Battery Information')] Sleep 2sVerify Battery Part Number [Arguments] ${expected_battery_part_number} # Scroll down until find "Battery Part Number" : FOR ${i} IN RANGE 20 \ Sleep 2s \ ${count} Get Matching Xpath Count xpath=//*[contains(@text, 'Battery Part Number')] \ Exit For Loop If ${count}>0 \ Swipe 400 1000 400 800 800 Log Verify the Page if contains the right battery part number Page Should Contain Text ${expected_battery_part_number} INFOVerify Battery Serial Number [Arguments] ${expected_battery_serial_number} # Scroll down until find "Battery Serial Number" : FOR ${i} IN RANGE 20 \ Sleep 2s \ ${count} Get Matching Xpath Count xpath=//*[contains(@text, 'Battery Serial Number')] \ Exit For Loop If ${count}>0 \ Swipe 400 1000 400 800 800 Log Verify the Page if contains the right battery serial number Page Should Contain Text ${expected_battery_serial_number} INFO
每个机器的UI都是不同的, 在其他机器上是无法直接运行的, 所以以上代码仅供参考.
文末列出最近整理的Robot Framework相关的文章,
1.Robot Framework 介绍
2.Robot Framework + Appium测试Android设备
3. Robot Framework如何向Android发送keycode键盘事件
4.Robot Framework如何判断Android屏幕是否含有某个控件
5.Robot Framework如何等待Android屏幕中的某个控件出现
6.Robot Framework如何在Android中实现滚屏
7.Robot Framework如何对Android的控件定位
8.Robot Framework+Appium案例分享一: 验证版本信息
9.Robot Framework+Appium案例分享二: Camera测试
10.Robot Framework+Appium案例分享三: WiFi测试
11.Robot Framework+Appium案例分享四: Bluetooth测试
12.RobotFramework AppiumLibrary 用户关键字
- Robot Framework+Appium案例分享一: 验证版本信息
- Robot Framework+Appium案例分享二: Camera测试
- Robot Framework+Appium案例分享三: WiFi测试
- Robot Framework+Appium案例分享四: Bluetooth测试
- 使用Robot Framework+Appium进行自动化
- Robot Framework +Appium的简单教程
- Robot Framework + Appium测试Android设备
- Robot Framework-Mac版本安装
- Robot Framework-Windows版本安装
- Mac OS X 下搭建Robot Framework+Appium环境
- Robot Framework + appium库 增加元素是否存在关键字
- Robot Framework +Appium的简单教程及实例
- robot framework 使用一:win7上搭建robot framework环境
- Robot Framework自动化测试 ---文档分享
- Robot Framework如何实现识别验证码
- robot framework selenium 指定浏览器版本启动
- Robot Framework 安装Tips (windows版本)
- Robot Framework自动化测试(一)
- 二维数组与数组指针
- Redis系列-1.介绍
- url 在chrome可以 firefox可以 IE报错?
- [安全漏洞公告专区]【漏洞公告】WordPress的Display Widgets插件存在后门
- 删除git本地分支遇到的一个小问题
- Robot Framework+Appium案例分享一: 验证版本信息
- 关于MYSQL 的 AUTO-INC Locks
- vcpu和cpu的关系
- 虚拟机下Linux Ubuntu装jdk过程
- 接口返回值统一对象
- python网络爬虫-数据采集之遍历单个爬虫
- SpringCloud(第 009 篇)简单 Quartz 微服务,不支持分布式
- 编程游戏联系网站
- hdu 2054 A==B?