160 likes | 373 Views
Athrun Instrument Driver. 太禅. Athrun 简介. Athrun 目标:自动化手段解决无线测试的问题 定位:无线自动化测试框架 / 平台 支持: Android / iOS 口号:让手机 run 起来! Open source at. Android 框架发展历程. iOS 框架发展历程. Athrun 远程平台. IOS 框架发展(一). 注入式框架 AppFramework 思路: 利用 didFinishLaunchingWithOptions 构造控件树 模拟 touch 事件 优点: iOS 各版本适用
E N D
Athrun简介 • Athrun • 目标:自动化手段解决无线测试的问题 • 定位:无线自动化测试框架/平台 • 支持:Android / iOS • 口号:让手机run起来! • Open source at
IOS框架发展(一) • 注入式框架AppFramework • 思路: • 利用didFinishLaunchingWithOptions • 构造控件树 • 模拟touch事件 • 优点: • iOS各版本适用 • Objective-C贴近开发 • 困难: • 需要修改开发代码 • 运行下个用例前,需要主动返回首页 • Objective-C对测试的学习成本
IOS框架发展(二) • instrument js扩展 • UIAutomation的调研 • 优点:录制、非注入 • 缺点:iOS 4.0以上支持,操作不稳定 • 我们对UIAutomation的扩展 • 操作扩展 • 校验扩展 • Log转Hudson • UIAutomation方案的困扰 • 录制难维护 • 低级错误,排错成本高 • 无法单步调试 • 服务端数据准备
IOS框架发展(三) • InstrumentDriver • 特点 • 使用java编写用例 • junit方式运行用例 • 优势 • 自动的语法检查,智能感知 • 支持断点单步调试、变量查看 • 更方便的持续集成和数据准备
API介绍 • API风格: • 面向UI对象 • 支持数组 • 与UIAutomation兼容 • 录制的脚本可以运行 • 根节点: • UIATarget • static localTarget() • printElementTree • scrollUp/Down/Left/Right • frontMostApp • UIAApplication • alert • keyboard • UIANavigationBar • mainWindow • win=UIATarget.localTarget().frontMostApp().mainWindow() • UIAWindow(win) • 继承自UIAElement • UIAElement • elements • T findElementByText(String text, Class<T> elmentType) • tap • touchAndHold
示例代码 @Test publicvoid Demo1() throws Exception { win.printElementTree(); win.findElementByText("Demo 1").touchAndHold(); UIAElement[] eles = win.elements(); System.out.println(eles.length); win.findElementByText("name", UIATextField.class).setValue("athrun"); win.secureTextFields()[0].tap(); app.keyboard().typeString("abcdefg\\n"); win.findElementByText("Hello Tao").tap(); assertEquals("Hello,athrun!", win.staticTexts()[3].name()); }
Demo演示 • 查看Demo • Demo-InstrumentDriver.mov
后续发展 • Todo List • 通信超时异常处理 • Debug开关IDE自动设置 • 使用Mac共享机,在Windows上运行用例 • 开源 • http://code.taobao.org/p/athrun/wiki/index/ • Welcome To • Notify bug • Make suggestion • Send patch