1. XCUIApplication

这是你正在测试的应用的代理。它能让你启动应用,这样你就能执行测试了。它每次都会新起一个进程,这会多花一些时间,但是能保证测试应用时的状态是干净的,这样你需要处理的变量就少了些。

  1. - (void)launch;//启动应用。如果目标应用已运行,首先终止应用,然后再次启动应用。
  2. - (void)terminate;//关闭应用。
  3. @property (nonatomic, copy) NSArray <NSString *> *launchArguments;//数组对象,保存启动参数。
  4. @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

  1. /*! The accessibility identifier. */
  2. @property (readonly) NSString *identifier;
  3.  
  4. /*! The frame of the element in the screen coordinate space. */
  5. @property (readonly) CGRect frame;
  6.  
  7. /*! The raw value attribute of the element. Depending on the element, the actual type can vary. */
  8. @property (readonly, nullable) id value;
  9.  
  10. /*! The title attribute of the element. */
  11. @property (readonly, copy) NSString *title;
  12.  
  13. /*! The label attribute of the element. */
  14. @property (readonly, copy) NSString *label;
  15.  
  16. /*! The type of the element. /seealso XCUIElementType. */
  17. @property (readonly) XCUIElementType elementType;
  18.  
  19. /*! Whether or not the element is enabled for user interaction. */
  20. @property (readonly, getter = isEnabled) BOOL enabled;
  21.  
  22. /*! The horizontal size class of the element. */
  23. @property (readonly) XCUIUserInterfaceSizeClass horizontalSizeClass;
  24.  
  25. /*! The vertical size class of the element. */
  26. @property (readonly) XCUIUserInterfaceSizeClass verticalSizeClass;
  27.  
  28. /*! The value that is displayed when the element has no value. */
  29. @property (readonly, nullable) NSString *placeholderValue;
  30.  
  31. /*! Whether or not the element is selected. */
  32. @property (readonly, getter = isSelected) BOOL selected;
  33.  
  34. #if TARGET_OS_TV
  35. /*! Whether or not the elment has UI focus. */
  36. @property (readonly) BOOL hasFocus;

4. XCUIElementTypeQueryProvider协议

  1. @property (readonly, copy) XCUIElementQuery *touchBars;
  2. @property (readonly, copy) XCUIElementQuery *groups;
  3. @property (readonly, copy) XCUIElementQuery *windows;
  4. @property (readonly, copy) XCUIElementQuery *sheets;
  5. @property (readonly, copy) XCUIElementQuery *drawers;
  6. @property (readonly, copy) XCUIElementQuery *alerts;
  7. @property (readonly, copy) XCUIElementQuery *dialogs;
  8. @property (readonly, copy) XCUIElementQuery *buttons;
  9. @property (readonly, copy) XCUIElementQuery *radioButtons;
  10. @property (readonly, copy) XCUIElementQuery *radioGroups;
  11. @property (readonly, copy) XCUIElementQuery *checkBoxes;
  12. @property (readonly, copy) XCUIElementQuery *disclosureTriangles;
  13. @property (readonly, copy) XCUIElementQuery *popUpButtons;
  14. @property (readonly, copy) XCUIElementQuery *comboBoxes;
  15. @property (readonly, copy) XCUIElementQuery *menuButtons;
  16. @property (readonly, copy) XCUIElementQuery *toolbarButtons;
  17. @property (readonly, copy) XCUIElementQuery *popovers;
  18. @property (readonly, copy) XCUIElementQuery *keyboards;
  19. @property (readonly, copy) XCUIElementQuery *keys;
  20. @property (readonly, copy) XCUIElementQuery *navigationBars;
  21. @property (readonly, copy) XCUIElementQuery *tabBars;
  22. @property (readonly, copy) XCUIElementQuery *tabGroups;
  23. @property (readonly, copy) XCUIElementQuery *toolbars;
  24. @property (readonly, copy) XCUIElementQuery *statusBars;
  25. @property (readonly, copy) XCUIElementQuery *tables;
  26. @property (readonly, copy) XCUIElementQuery *tableRows;
  27. @property (readonly, copy) XCUIElementQuery *tableColumns;
  28. @property (readonly, copy) XCUIElementQuery *outlines;
  29. @property (readonly, copy) XCUIElementQuery *outlineRows;
  30. @property (readonly, copy) XCUIElementQuery *browsers;
  31. @property (readonly, copy) XCUIElementQuery *collectionViews;
  32. @property (readonly, copy) XCUIElementQuery *sliders;
  33. @property (readonly, copy) XCUIElementQuery *pageIndicators;
  34. @property (readonly, copy) XCUIElementQuery *progressIndicators;
  35. @property (readonly, copy) XCUIElementQuery *activityIndicators;
  36. @property (readonly, copy) XCUIElementQuery *segmentedControls;
  37. @property (readonly, copy) XCUIElementQuery *pickers;
  38. @property (readonly, copy) XCUIElementQuery *pickerWheels;
  39. @property (readonly, copy) XCUIElementQuery *switches;
  40. @property (readonly, copy) XCUIElementQuery *toggles;
  41. @property (readonly, copy) XCUIElementQuery *links;
  42. @property (readonly, copy) XCUIElementQuery *images;
  43. @property (readonly, copy) XCUIElementQuery *icons;
  44. @property (readonly, copy) XCUIElementQuery *searchFields;
  45. @property (readonly, copy) XCUIElementQuery *scrollViews;
  46. @property (readonly, copy) XCUIElementQuery *scrollBars;
  47. @property (readonly, copy) XCUIElementQuery *staticTexts;
  48. @property (readonly, copy) XCUIElementQuery *textFields;
  49. @property (readonly, copy) XCUIElementQuery *secureTextFields;
  50. @property (readonly, copy) XCUIElementQuery *datePickers;
  51. @property (readonly, copy) XCUIElementQuery *textViews;
  52. @property (readonly, copy) XCUIElementQuery *menus;
  53. @property (readonly, copy) XCUIElementQuery *menuItems;
  54. @property (readonly, copy) XCUIElementQuery *menuBars;
  55. @property (readonly, copy) XCUIElementQuery *menuBarItems;
  56. @property (readonly, copy) XCUIElementQuery *maps;
  57. @property (readonly, copy) XCUIElementQuery *webViews;
  58. @property (readonly, copy) XCUIElementQuery *steppers;
  59. @property (readonly, copy) XCUIElementQuery *incrementArrows;
  60. @property (readonly, copy) XCUIElementQuery *decrementArrows;
  61. @property (readonly, copy) XCUIElementQuery *tabs;
  62. @property (readonly, copy) XCUIElementQuery *timelines;
  63. @property (readonly, copy) XCUIElementQuery *ratingIndicators;
  64. @property (readonly, copy) XCUIElementQuery *valueIndicators;
  65. @property (readonly, copy) XCUIElementQuery *splitGroups;
  66. @property (readonly, copy) XCUIElementQuery *splitters;
  67. @property (readonly, copy) XCUIElementQuery *relevanceIndicators;
  68. @property (readonly, copy) XCUIElementQuery *colorWells;
  69. @property (readonly, copy) XCUIElementQuery *helpTags;
  70. @property (readonly, copy) XCUIElementQuery *mattes;
  71. @property (readonly, copy) XCUIElementQuery *dockItems;
  72. @property (readonly, copy) XCUIElementQuery *rulers;
  73. @property (readonly, copy) XCUIElementQuery *rulerMarkers;
  74. @property (readonly, copy) XCUIElementQuery *grids;
  75. @property (readonly, copy) XCUIElementQuery *levelIndicators;
  76. @property (readonly, copy) XCUIElementQuery *cells;
  77. @property (readonly, copy) XCUIElementQuery *layoutAreas;
  78. @property (readonly, copy) XCUIElementQuery *layoutItems;
  79. @property (readonly, copy) XCUIElementQuery *handles;
  80. @property (readonly, copy) XCUIElementQuery *otherElements;

2. UITest相关APIs的更多相关文章

  1. Python 资源大全中文版

    Python 资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列的资源整理.awesome-python 是 vinta 发起维护的 Python 资源列 ...

  2. [转载]Python 资源大全

    原文链接:Python 资源大全 环境管理 管理 Python 版本和环境的工具 p – 非常简单的交互式 python 版本管理工具. pyenv – 简单的 Python 版本管理工具. Vex  ...

  3. python常用库

    本文由 伯乐在线 - 艾凌风 翻译,Namco 校稿.未经许可,禁止转载!英文出处:vinta.欢迎加入翻译组. Awesome Python ,这又是一个 Awesome XXX 系列的资源整理,由 ...

  4. webkit事件处理

    1,概述 原文地址:http://blog.csdn.net/awebkit/article/details/8493716 浏览器处理事件一般有两个过程,捕获过程和冒泡过程,这是由addEventL ...

  5. iOS 7中实现模糊效果

    本文译自iOS 7 Blur Effects with GPUImage. iOS 7在视觉方面有许多改变,其中非常吸引人的功能之一就是在整个系统中巧妙的使用了模糊效果.许多第三方应用程序已经采用了这 ...

  6. Java 开源博客——B3log Solo 0.6.6 正式版公布了!

    Java 开源博客 -- B3log Solo 0.6.6 正式版公布了!欢迎大家下载. 该版本号引入了数据库连接池:Druid. 另外,欢迎观摩 B3log 团队的新项目:Noty,也很欢迎大家參与 ...

  7. Python 库大全

    作者:Lingfeng Ai链接:http://www.zhihu.com/question/24590883/answer/92420471来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非 ...

  8. Java 开源博客——B3log Solo 0.6.7 正式版公布了!

    Java 开源博客 -- B3log Solo 0.6.7 正式版公布了!欢迎大家下载. 另外,欢迎观摩 B3log 团队的新项目:Wide,也很欢迎大家參与进来 :-) 特性 基于标签的文章分类 P ...

  9. Java 开源博客——B3log Solo 0.6.1 正式版发布了!

    Java 开源博客 —— B3LOG Solo 0.6.1 正式版发布了!欢迎大家下载. 该版本主要是改善细节体验,并加入了一款 Metro 风格的皮肤. 特性 基于标签的文章分类 Ping Goog ...

随机推荐

  1. Unable to resolve target android-5解决方案

    1:问题:android导入项目的时候出现此错误 2:原因: 3:解决: 修改工程目录下的default.properties文件里的内容target=android-5 这个5修改成你的api版本就 ...

  2. Android 5.x SEAndroid/SElinux内核节点的读写权限【学习笔记】

    本文转载自:http://blog.csdn.net/tung214/article/details/44461985 Android 5.0下,因为采取了SEAndroid/SElinux的安全机制 ...

  3. 【Java】DateUtil(1)

    import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; impor ...

  4. 关于布局(Layout)的一切

    之前在布局中有很多问题也有很多经验,遗憾都没记下来.现在一点点记下一些东西. 1.外层用LinearLayout的话,常常把orientation设成vertical, android:orienta ...

  5. BZOJ_2683_简单题&&BZOJ_1176_[Balkan2007]Mokia_CDQ分治+树状数组

    BZOJ_2683_简单题&&BZOJ_1176_[Balkan2007]Mokia_CDQ分治+树状数组 Description 维护一个W*W的矩阵,初始值均为S.每次操作可以增加 ...

  6. DLL远程注入实例

    一般情况下,每个进程都有自己的私有空间,理论上,别的进程是不允许对这个私人空间进行操作的,但是,我们可以利用一些方法进入这个空间并进行操作,将自己的代码写入正在运行的进程中,于是就有了远程注入了. 对 ...

  7. ASP.NET Core:目录

    ylbtech-ASP.NET Core:目录 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http:// ...

  8. HTML <legend> 标签

    转自:https://www.w3cschool.cn/htmltags/tag-legend.html <!DOCTYPE HTML> <html> <body> ...

  9. python int对象的方法

    1.求绝对值 >>> a = -10 >>> a.__abs__() 10 >>> abs(10) 10 2.加法 >>> a ...

  10. python iteration 迭代

    可迭代的类型:list,tuple,dict,str,bytes,bytearray等 一.怎么判断一个对象是否可迭代 >>> from collections import Ite ...