2. UITest相关APIs
1. XCUIApplication
这是你正在测试的应用的代理。它能让你启动应用,这样你就能执行测试了。它每次都会新起一个进程,这会多花一些时间,但是能保证测试应用时的状态是干净的,这样你需要处理的变量就少了些。
- (void)launch;//启动应用。如果目标应用已运行,首先终止应用,然后再次启动应用。
- (void)terminate;//关闭应用。
@property (nonatomic, copy) NSArray <NSString *> *launchArguments;//数组对象,保存启动参数。
@property (nonatomic, copy) NSDictionary <NSString *, NSString *> *launchEnvironment;//字典对象,保存启动环境变量
2. XCUIElement
这是你正在测试的应用中UI元素的代理。每个元素都有类型和标识符,结合二者就能找到应用中的UI元素。所有的元素都会嵌套在代表你的应用的树中。
@property (readonly) BOOL exists;
这个控件是否存在(不管被遮挡或者不在当前屏幕内都是YES)
@property (readonly, getter = isHittable) BOOL hittable;
这个控件是否能找到一个点可以点击
- (XCUIElementQuery *)descendantsMatchingType \:(XCUIElementType)type;
在这个元素里按照固定的类型寻找其所有的子元素,如:
在Table的Cell里寻找所有的子Button
locButton = [cell descendantsMatchingType:XCUIElementTypeButton];
- (XCUIElementQuery *)childrenMatchingType \:(XCUIElementType)type;
在这个元素里按照固定的类型寻找其所有直接的子元素(即无法查找子元素的子元素),和上一个方法类似。
- (XCUICoordinate *)coordinateWithNormalizedOffset \:(CGVector)normalizedOffset;
在这个控件里根据CGVector的比例返回一个点。
XCUICoordinate *bot = [window coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.5)];//在Window中X比例为0.5,Y比例为0.5的一个点
@property (readonly, copy) NSString *debugDescription;
上面已经叙述过了,就是查询的调试信息。
- (void)typeText :(NSString *)text;
可以用这个方法对UITextField 和 UITextView等输入,但调用之前需要确保键盘已经弹出,否则会出错。
- (void)tap;
单击这个控件一次
- (void)doubleTap;
双击这个控件一次
- (void)twoFingerTap;
双指点击
- (void)tapWithNumberOfTaps :(NSUInteger)numberOfTaps numberOfTouches :(NSUInteger)numberOfTouches;
可以指定点击几次,每次用几个手指
- (void)pressForDuration :(NSTimeInterval)duration;
长按手势,可以指定长按的时间。
- (void)pressForDuration :(NSTimeInterval)duration thenDragToElement :(XCUIElement *)otherElement;
先长按然后再拖动到另一个元素的位置,多用于TableView的MoveCell。
- (void)swipeUp;
- (void)swipeDown;
- (void)swipeLeft;
- (void)swipeRight;
上下左右滑动的手势。
- (void)pinchWithScale \:(CGFloat)scale velocity :(CGFloat)velocity;
Pinch的手势。
- (void)rotate \:(CGFloat)rotation withVelocity :(CGFloat)velocity;
旋转的手势。
- (void)adjustToNormalizedSliderPosition :(CGFloat)normalizedSliderPosition;
设置一个Slider当前的Value值,设置的值的范围在[0 , 1]。
@property (readonly) CGFloat normalizedSliderPosition;
返回一个Slider当前Value的值,值的范围在[0 , 1]。
- (void)adjustToPickerWheelValue :(NSString *)pickerWheelValue;
设置一个PikerView的值为多少。
3. XCUIElementAttributes
/*! The accessibility identifier. */
@property (readonly) NSString *identifier; /*! The frame of the element in the screen coordinate space. */
@property (readonly) CGRect frame; /*! The raw value attribute of the element. Depending on the element, the actual type can vary. */
@property (readonly, nullable) id value; /*! The title attribute of the element. */
@property (readonly, copy) NSString *title; /*! The label attribute of the element. */
@property (readonly, copy) NSString *label; /*! The type of the element. /seealso XCUIElementType. */
@property (readonly) XCUIElementType elementType; /*! Whether or not the element is enabled for user interaction. */
@property (readonly, getter = isEnabled) BOOL enabled; /*! The horizontal size class of the element. */
@property (readonly) XCUIUserInterfaceSizeClass horizontalSizeClass; /*! The vertical size class of the element. */
@property (readonly) XCUIUserInterfaceSizeClass verticalSizeClass; /*! The value that is displayed when the element has no value. */
@property (readonly, nullable) NSString *placeholderValue; /*! Whether or not the element is selected. */
@property (readonly, getter = isSelected) BOOL selected; #if TARGET_OS_TV
/*! Whether or not the elment has UI focus. */
@property (readonly) BOOL hasFocus;
4. XCUIElementTypeQueryProvider协议
@property (readonly, copy) XCUIElementQuery *touchBars;
@property (readonly, copy) XCUIElementQuery *groups;
@property (readonly, copy) XCUIElementQuery *windows;
@property (readonly, copy) XCUIElementQuery *sheets;
@property (readonly, copy) XCUIElementQuery *drawers;
@property (readonly, copy) XCUIElementQuery *alerts;
@property (readonly, copy) XCUIElementQuery *dialogs;
@property (readonly, copy) XCUIElementQuery *buttons;
@property (readonly, copy) XCUIElementQuery *radioButtons;
@property (readonly, copy) XCUIElementQuery *radioGroups;
@property (readonly, copy) XCUIElementQuery *checkBoxes;
@property (readonly, copy) XCUIElementQuery *disclosureTriangles;
@property (readonly, copy) XCUIElementQuery *popUpButtons;
@property (readonly, copy) XCUIElementQuery *comboBoxes;
@property (readonly, copy) XCUIElementQuery *menuButtons;
@property (readonly, copy) XCUIElementQuery *toolbarButtons;
@property (readonly, copy) XCUIElementQuery *popovers;
@property (readonly, copy) XCUIElementQuery *keyboards;
@property (readonly, copy) XCUIElementQuery *keys;
@property (readonly, copy) XCUIElementQuery *navigationBars;
@property (readonly, copy) XCUIElementQuery *tabBars;
@property (readonly, copy) XCUIElementQuery *tabGroups;
@property (readonly, copy) XCUIElementQuery *toolbars;
@property (readonly, copy) XCUIElementQuery *statusBars;
@property (readonly, copy) XCUIElementQuery *tables;
@property (readonly, copy) XCUIElementQuery *tableRows;
@property (readonly, copy) XCUIElementQuery *tableColumns;
@property (readonly, copy) XCUIElementQuery *outlines;
@property (readonly, copy) XCUIElementQuery *outlineRows;
@property (readonly, copy) XCUIElementQuery *browsers;
@property (readonly, copy) XCUIElementQuery *collectionViews;
@property (readonly, copy) XCUIElementQuery *sliders;
@property (readonly, copy) XCUIElementQuery *pageIndicators;
@property (readonly, copy) XCUIElementQuery *progressIndicators;
@property (readonly, copy) XCUIElementQuery *activityIndicators;
@property (readonly, copy) XCUIElementQuery *segmentedControls;
@property (readonly, copy) XCUIElementQuery *pickers;
@property (readonly, copy) XCUIElementQuery *pickerWheels;
@property (readonly, copy) XCUIElementQuery *switches;
@property (readonly, copy) XCUIElementQuery *toggles;
@property (readonly, copy) XCUIElementQuery *links;
@property (readonly, copy) XCUIElementQuery *images;
@property (readonly, copy) XCUIElementQuery *icons;
@property (readonly, copy) XCUIElementQuery *searchFields;
@property (readonly, copy) XCUIElementQuery *scrollViews;
@property (readonly, copy) XCUIElementQuery *scrollBars;
@property (readonly, copy) XCUIElementQuery *staticTexts;
@property (readonly, copy) XCUIElementQuery *textFields;
@property (readonly, copy) XCUIElementQuery *secureTextFields;
@property (readonly, copy) XCUIElementQuery *datePickers;
@property (readonly, copy) XCUIElementQuery *textViews;
@property (readonly, copy) XCUIElementQuery *menus;
@property (readonly, copy) XCUIElementQuery *menuItems;
@property (readonly, copy) XCUIElementQuery *menuBars;
@property (readonly, copy) XCUIElementQuery *menuBarItems;
@property (readonly, copy) XCUIElementQuery *maps;
@property (readonly, copy) XCUIElementQuery *webViews;
@property (readonly, copy) XCUIElementQuery *steppers;
@property (readonly, copy) XCUIElementQuery *incrementArrows;
@property (readonly, copy) XCUIElementQuery *decrementArrows;
@property (readonly, copy) XCUIElementQuery *tabs;
@property (readonly, copy) XCUIElementQuery *timelines;
@property (readonly, copy) XCUIElementQuery *ratingIndicators;
@property (readonly, copy) XCUIElementQuery *valueIndicators;
@property (readonly, copy) XCUIElementQuery *splitGroups;
@property (readonly, copy) XCUIElementQuery *splitters;
@property (readonly, copy) XCUIElementQuery *relevanceIndicators;
@property (readonly, copy) XCUIElementQuery *colorWells;
@property (readonly, copy) XCUIElementQuery *helpTags;
@property (readonly, copy) XCUIElementQuery *mattes;
@property (readonly, copy) XCUIElementQuery *dockItems;
@property (readonly, copy) XCUIElementQuery *rulers;
@property (readonly, copy) XCUIElementQuery *rulerMarkers;
@property (readonly, copy) XCUIElementQuery *grids;
@property (readonly, copy) XCUIElementQuery *levelIndicators;
@property (readonly, copy) XCUIElementQuery *cells;
@property (readonly, copy) XCUIElementQuery *layoutAreas;
@property (readonly, copy) XCUIElementQuery *layoutItems;
@property (readonly, copy) XCUIElementQuery *handles;
@property (readonly, copy) XCUIElementQuery *otherElements;
2. UITest相关APIs的更多相关文章
- Python 资源大全中文版
Python 资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列的资源整理.awesome-python 是 vinta 发起维护的 Python 资源列 ...
- [转载]Python 资源大全
原文链接:Python 资源大全 环境管理 管理 Python 版本和环境的工具 p – 非常简单的交互式 python 版本管理工具. pyenv – 简单的 Python 版本管理工具. Vex ...
- python常用库
本文由 伯乐在线 - 艾凌风 翻译,Namco 校稿.未经许可,禁止转载!英文出处:vinta.欢迎加入翻译组. Awesome Python ,这又是一个 Awesome XXX 系列的资源整理,由 ...
- webkit事件处理
1,概述 原文地址:http://blog.csdn.net/awebkit/article/details/8493716 浏览器处理事件一般有两个过程,捕获过程和冒泡过程,这是由addEventL ...
- iOS 7中实现模糊效果
本文译自iOS 7 Blur Effects with GPUImage. iOS 7在视觉方面有许多改变,其中非常吸引人的功能之一就是在整个系统中巧妙的使用了模糊效果.许多第三方应用程序已经采用了这 ...
- Java 开源博客——B3log Solo 0.6.6 正式版公布了!
Java 开源博客 -- B3log Solo 0.6.6 正式版公布了!欢迎大家下载. 该版本号引入了数据库连接池:Druid. 另外,欢迎观摩 B3log 团队的新项目:Noty,也很欢迎大家參与 ...
- Python 库大全
作者:Lingfeng Ai链接:http://www.zhihu.com/question/24590883/answer/92420471来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非 ...
- Java 开源博客——B3log Solo 0.6.7 正式版公布了!
Java 开源博客 -- B3log Solo 0.6.7 正式版公布了!欢迎大家下载. 另外,欢迎观摩 B3log 团队的新项目:Wide,也很欢迎大家參与进来 :-) 特性 基于标签的文章分类 P ...
- Java 开源博客——B3log Solo 0.6.1 正式版发布了!
Java 开源博客 —— B3LOG Solo 0.6.1 正式版发布了!欢迎大家下载. 该版本主要是改善细节体验,并加入了一款 Metro 风格的皮肤. 特性 基于标签的文章分类 Ping Goog ...
随机推荐
- golang-----golang sync.WaitGroup解决goroutine同步
go提供了sync包和channel来解决协程同步和通讯.新手对channel通道操作起来更容易产生死锁,如果时缓冲的channel还要考虑channel放入和取出数据的速率问题. 从字面就可以理解, ...
- Hive 自定义函数 UDF UDAF UDTF
1.UDF:用户定义(普通)函数,只对单行数值产生作用: 继承UDF类,添加方法 evaluate() /** * @function 自定义UDF统计最小值 * @author John * */ ...
- OpenSSL生成CA证书及终端用户证书
环境 OpenSSL 1.0.2k FireFox 60.0 64位 Chrome 66.0.3359.181 (正式版本)(32位) Internet Explorer 11.2248.14393. ...
- POJ 1861 Network (Kruskal算法+输出的最小生成树里最长的边==最后加入生成树的边权 *【模板】)
Network Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 14021 Accepted: 5484 Specia ...
- CSS animation-timing-function 属性中的 steps() 与 step-start,step-end
steps() 设置间隔参数,可以实现分步过渡 第一个参数指定了时间函数中的间隔数量(必须是正整数)第二个参数可选,接受 start 和 end 两个值,指定在每个间隔的起点或是终点发生阶跃变化,默认 ...
- Digit(湘潭大学比赛)
题目链接: 点击打开链接 中文问题目就不解释了. 思路,找到这个数对应的的数字是多少,然后对这个数取对应的位置. 步骤:先打表打出一位数字对应字符串的长度,两位数的,到8,9就差不多了. 先确定给定的 ...
- flask中manage.py的用法
flask中manage.py的用法#!/usr/bin/env pythonimport osfrom app import create_app, dbfrom app.models import ...
- bzoj 4756 Promotion Counting —— 线段树合并
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4756 合并子树的权值线段树: merge 返回 int 或者是 void 都可以. 代码如下 ...
- ASP.NET Core MVC 2.x 全面教程_ASP.NET Core MVC 23. 继续讲Tag Helpers 和复习View Component
当条件为true就渲染,否则就不渲染 ‘ 判断用户的登陆 更好的一点是做一个TagHelper.把这些明显的C#代码都去掉.最终都是用html和属性的形式来组成一个最终的代码 属性名称等于Confit ...
- [ssh]记ssh的几种玩法
得到一台Linux的服务器,我们可以进行以下几种玩法: 先讲一讲几个参数: -f 要求 ssh在执行命令前退至后台.它用于当ssh准备询问口令或密语,但是用户希望它在后台进行.该选项隐含了-n选 ...