Quick Start:
Please refer to:
中文教程:
WWDC15 Session笔记 - Xcode 7 UI 测试初窥
Official Guide:
Apple Official Guide—— UI Testing in Xcode
Blog&Articles:
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:
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:
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.
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.
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.
Evaluates the query and returns the number of elements that match.
The query's single matching element.
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.
Returns a descendant element matching the identifier specified bykey.