利用Robot Framework和Python wrapper of Android uiautomator的Android测试自动化
来源:互联网 发布:医院预约管理系统php 编辑:程序博客网 时间:2024/05/01 13:48
现在有很多工具可以实现BDD,比如Cucumber(http://cukes.info/),用文本来描述行为和结果
不会编程的人看得懂,当然了,底下的工作并没有减少。
这个Robot框架好处有两点,1. 适用广泛,可配置高 2. 报告可读性高
今天我们来弄一下这个过程,比较简单,错误之处希望海函。
1. Robot framework 安装
下载:http://robotframework.org/
安装:sudo python setup.py install
2. 安装https://github.com/xiaocong/uiautomato
sudo pip install uiautomator
echo "export ANDROID_HOME=/your_android_home" > > ~./bashrc
source ~/.bashrc
3. 写用例文本(宏文本)
比如我们这个keyword-driven.txt,按照keyword来写的,注意要用很多tab来分割函数和参数
*** Settings ***Documentation Example test cases using the keyword-driven testing approach....... All tests contain a workflow constructed from keywords in... `UiTestLib`. Creating new tests or editing existing... is easy even for people without programming skills.Library UiTestLib*** Test Cases ***点亮屏幕 Light screen Result should be True打开声音 Open application "com.android.settings/com.android.settings.Settings" Click text 声音 Click text 音量 Text display on screen contains 铃声和通知 Result should be True
4. 写底层解析脚本
用来解析上面的宏文本,可以看到它是以下划线来命名解析的,只有这样才能达到一一对应。
#!/usr/bin/env python# -*- coding: utf-8 -*-import uiautomatorfrom uiautomator import Adb, Deviceclass UiTestLib(object): """Test library for testing Calculator business logic. Interacts with the calculator directly using its `push` method. """ def __init__(self): self.d = Device('CB512611AE') self.adb = Adb('CB512611AE') self._result = '' def light_screen(self): """Light screen by wakeup. Examples: |Light screen| Use `Light screen` to light screen. """ self.d.wakeup() self._result = self.d.press.home() def open_application(self, appname): """Open application by it name `appname`. Example: | Open application | "com.android.settings/com.android.settings.Settings" | """ appname = 'shell am start -n ' + appname print appname self._result = self.adb.cmd(appname).wait() def click_text(self, text): """Click text label on screen Example: | Click text | text | """ self.d(text = text).click.wait() def text_display_on_screen_contains(self, text): """Verify text display on screen Example: |Text display on screen is| text | """ if self.d(text=text).exists: self._result = True def result_should_be(self, expected): """Verifies that the current result is `expected`. Example: | Open application | com.android.settings/com.android.settings.Settings | | Result Should Be | 0 | """ print ( 'result is: %s\n', self._result) print ( 'ex is: %s\n', expected) if str(self._result) != expected: raise AssertionError('%s != %s' % (self._result, expected))
5. 运行
pybot keyword_driven.txt
结果就出来了,可读性很强,报告很强大。
0 0
- 利用Robot Framework和Python wrapper of Android uiautomator的Android测试自动化
- Python wrapper of Android uiautomator test tool
- Python + Android + Uiautomator自动化测试
- Python + Android + Uiautomator自动化测试
- Android进阶--android自动化测试python+uiautomator
- android uiautomator自动化测试
- UiAutomator android自动化测试
- Android-自动化测试UIAutomator
- Android自动化测试uiautomator
- Android UiAutoMator自动化测试
- Android Uiautomator 自动化测试
- Android Uiautomator 自动化测试
- Robot Framework自动化测试框架(三):Android自动化
- Android studio 下的Uiautomator自动化测试
- Android自动化测试之UIAutomator
- Android自动化测试(UiAutomator)
- Android自动化测试工具uiautomator
- Android自动化测试之UIAutomator
- 2862--勾股定理
- java实现Img与PDF相互转换
- memset()函数的应用
- A*算法(转)
- SWF 文件不能访问本地资源
- 利用Robot Framework和Python wrapper of Android uiautomator的Android测试自动化
- Windows应用程序高级控件之ImageList
- 算法导论堆排序java实现
- VS2010 无法打开包括文件:“iostream.h”: No such file or directory
- 清除浮动
- FIREFOX和CHROME浏览器下PercentLoaded()不能使用的解决方案
- windows中修改catalina.sh上传到linux执行报错This file is needed to run this program
- Qt5.3里使用X264库将y4m文件进行压缩
- MSOCache文件夹能否删除?