XCUITest - Guide

Quick Start:

Please refer to:

中文教程:

WWDC15 Session笔记 - Xcode 7 UI 测试初窥 

Official Guide:

Apple Official Guide—— UI Testing in Xcode

Blog&Articles:

UI Testing in Xcode 7

A Guide to XCode UI Test

Getting started with XCUITest framework for testing iOS apps.

Tips:

Suggested framework:

1.Long-run environment, define the configuration of the environment previously and make sure the testcase will recover the environment each time;

2.FrameWork Suggestion:


XCUI Framwork

Debug Related:

a. remember to add break-point at the end(or anywhere you want to pause) of your scripts when debugging, otherwise the log will be swept by the Application logs!

b. if you want to start recording from anywhere, just add a break-point before running the scripts, when the program paused you can then start recording from the point;

c.The debugging information will show you the sub-tree and how it is find by, it's very useful in defining the element.

General Issues:

1.no identitier, the sub-tree is changing frequently;

2.Testers exhausted to maintain the scripts;

3.framework bug;

4.The environment is not steady;

API :

Debugging Element Queries:

vardebugDescription: String

Provides debugging information about the query.

Creating New Queries:

func children(matching: XCUIElement.Type)

Returns a new query that matches all direct children of the requested type.

func descendants(matching: XCUIElement.Type)

Returns a new query that matches all descendants of the requested type.

func containing(NSPredicate)

Returns a new query that matches all elements containing a descendant that matches the provided predicate.

func containing(XCUIElement.Type,identifier: String?)

Returns a new query that matches all elements containing an element of the requested type, optionally also matching a specified identifier.

func matching(identifier: String)

Returns a new query that matches all elements with the provided identifier.

func matching(NSPredicate)

Returns a new query that matches all elements directly matching the provided predicate.

func matching(XCUIElement.Type,identifier: String?)

Returns a new query that matches all elements of the requested type, optionally also matching a specific identifier.

Accessing Matched Elements

var allElementsBoundByAccessibilityElement: [XCUIElement]

Immediately evaluates the query and returns an array of elements bound to the resulting accessibility elements.

var allElementsBoundByIndex: [XCUIElement]

Immediately evaluates the query and returns an array of elements bound by the index of each result.

var count: Int

Evaluates the query and returns the number of elements that match.

var element: XCUIElement

The query's single matching element.

func element(boundBy: Int)

An element that uses an index into the query's results to determine which underlying accessibility element to use.

func element(matching: NSPredicate)

An element that matches the predicate.

func element(matching: XCUIElement.Type,identifier: String?)

An element that matches the provided element type and identifier.

subscript(String)

Returns a descendant element matching the identifier specified bykey.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,811评论 0 23
  • 每一个人的一生都有精彩的时刻,哪怕是个乞丐或流浪汉。俗话说“莫欺少年穷”,可能遇到一时的困难或坎坷,只要努力去消除...
    红尘浪浪阅读 186评论 0 0
  • 概要 通过偶然的机会得知了7-11日本创始人铃木敏文的这两本书. 买来以后, 断断续续用一个月的时间读完了. 这两...
    每天多一点阅读 352评论 0 2
  • 今天真的有点小忙,从早上上班就开始忙,一直到刚刚结束到家。工作中挤出的一点点时间看了一下英语,如果是用来写作的话...
    snailwww阅读 130评论 0 2
  • 3-24 【仪封人请见。曰:君子之至于斯也,吾未尝不得见也。从者见之。出曰:二三子,何患于丧乎?天下之无道也久矣,...
    空空的山谷阅读 462评论 0 0