instruments学习笔记
来源:互联网 发布:张维为 知乎 编辑:程序博客网 时间:2024/06/07 01:35
//调用外部js
#import “../common/common.js”
//导航栏操作
UIATarget.localTarget().frontMostApp().navigationBar().leftButton().tap(); //点击左侧按钮
UIATarget.localTarget().frontMostApp().navigationBar().rightButton().tap(); //点击右侧按钮
//按钮点击
UIATarget.localTarget().frontMostApp().mainWindow().buttons()[“xxxxx”].tap();
//坐标点击
UIATarget.localTarget().tap({x:30,y:131});
//等待n秒,delay(n)
UIATarget.localTarget().delay(3);
//截图
UIATarget.localTarget().captureScreenWithName(“picname”);
//获取对象数组长度,length
UIATarget.localTarget().frontMostApp().mainWindow().buttons().length;
//获取文本字符串,value()
UIATarget.localTarget().frontMostApp().mainWindow().scrollViews()[0].staticTexts()[0].value();
//滚轮滚动,dragInsideWithOptions()
UIATarget.localTarget().frontMostApp().mainWindow().pickers()[0].wheels()[0].dragInsideWithOptions({startOffset:{x:0.38, y:0.66}, endOffset:{x:0.38, y:0.12}, duration:1.6});
//根据name模糊查询控件,firstWithPredicate(“name beginswith ‘xxx'”)
obj= window.tableViews()[0].cells().firstWithPredicate(“name beginswith ‘hello'”);
//根据name完全匹配,firstWithName(“xxxx”)
obj= window.tableViews()[0].cells().firstWithName(“hello world”);
//根据key值匹配,firstWithValueForKey(value,key)
obj= window.tableViews()[0].cells().firstWithValueForKey(“hello world”,”name”);
//拖动
window.tableViews()[0].scrollDown();
window.tableViews()[0].scrollUp();
window.tableViews()[0].scrollLeft();
window.tableViews()[0].scrollRight();
//打印当前屏幕所有空间信息
UIATarget.localTarget().logElementTree();
//记录日志
UIALogger.logStart(“start”);
UIALogger.logPass(“pass”);
UIALogger.logWarning(“warning”);
UIALogger.logFail(“fail”);
UIALogger.logMessage(“message”);
UIALogger.logError(“error”);
UIALogger.logDebug(“debug”);
UIALogger.logIssue(“issue”);
//九宫格搜索输入框
UIATarget.localTarget().frontMostApp().mainWindow().searchBars()[0]
//模拟键盘操作,keyboard().typeString(“xxx”)
UIATarget.localTarget().frontMostApp().keyboard().typeString(“aaa\n”);
\n=回车
//输入框输入,setValue()
UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[“Empty list”].cells()[“用户名:”].textFields()[0].setValue(“abcd”);
被测应用中有出现alert对话框,需要点击处理。绕了很多弯路,回头想想其实很简单。
1. onAlert事件要放在执行代码前面
2. onAlert事件中return值需要为true。如果是false,系统自动点击cancel按钮,如果cancel按钮不存在,则点击默认按钮。
3. 按顺序写执行代码即可
var target = UIATarget.localTarget();
UIATarget.onAlert = function onAlert(alert) {
var title = alert.name();
UIALogger.logWarning(“Alert with title ‘” + title + “‘ encountered.”);
// return false to use the default handler
return true;
}
target.frontMostApp().mainWindow().tableViews()[“空列表”].cells()[“xxx, 用户注销”].tap();
// Alert detected. Expressions for handling alerts should be moved into the UIATarget.onAlert function definition.
target.frontMostApp().alert().defaultButton().tap();
使用logStart后,后续的log记录,都会标记为其子集,可收起、展开显示,直到遇到logPass、logFail、logIssue,才结束这一层级。
- instruments学习笔记
- Instruments文档阅读笔记
- Instruments文档阅读笔记
- xcode instruments 学习
- Xcode 8 Instruments 学习
- Xcode 8 Instruments 学习
- Instruments使用之初步学习
- instruments
- Instruments
- Instruments
- Xcode 8 Instruments 学习(二)
- Xcode 8 Instruments 学习(一)
- Xcode 8 Instruments 学习(一)
- IOS 开发学习二十一 instruments使用 quick start
- 代码优化工具:Instruments学习&nbs…
- 转自Xcode 8 Instruments 学习(二)
- Instruments使用
- Instruments 使用
- Android从摄像头或相册中获取照片
- 安卓中自定义view控件代替radiogroup实现颜色渐变效果的写法
- CI框架源码研读(路由解析)
- Core Java Volume I Coding Practices
- Java中3DES加密解密调用示例
- instruments学习笔记
- java(5)------break和continue
- iOS应用架构谈 网络层设计方案
- Oracle创建、重建和删除索引
- Xshell无法连接Ubuntu,但能够ping通虚拟机
- 《计算机系统要素》学习笔记: 逻辑门 构建 思路
- 用Java的加密机制来保护你的数据
- iOS应用架构谈 本地持久化方案及动态部署
- Lab 6:Linux系统调用