Xcode 7 UI Testing
Four new classes
One new protocol
Three new constants
XCUIApplication Class: launch(), terminate(),
**launchArguments(), launchEnvironment() : No Documentation
Resets app instance and provides clean state for each TestCase class
Set specific arguments or environments variables at launch.
Usage: class DemoTestClass: XCTestCase {
override func setUp() {
super.setUp()
continueAfterFailure = false
XCUIApplication().launch()
}
XCUIElement Class: .exists,
descendentMatchingType(type: XCUIElementType),
childrenMatchingType(type: XCUIElementType),
debugDescription
Extensions: tap(), pressForDuration(), swipeUp() , typeText() …
Representation of UI controls on the views.Elements are described in terms
of queries, XCElementQuery.
Usage:
let app = XCUIApplication()
app.navigationBars["All"].buttons["Favorites"].tap()
XCUIElementQuery Class: .element, .count
elementAtIndex(index : UInt)
elementMatchingPredicate(predicate: NSPredicate)
.allElementsBoundByIndex
Helps uniquely locate the UI control to interact with during execution.Provides
objects for locating elements which can be chained with other queries.
Usage:
app.collectionViews.childrenMatchingType(.Cell).elementAtIndex(1).images["AA
PLRemoveControl"].doubleTap()
XCUIDevice Class:
sharedDevice()
Orientation()
Represents a Device, interface for simulating events involving physical
buttons and device state.
Usage:
XCUIDevice = sharedDevice()
UIDeviceOrientation XCUIDevice.orientation(value)
XCTest Assertion Classes:
XCTAssert()
XCTAssertEquals()
XCTAssertNotNil()
Since XCUI* is extension of XCTest, all existing assertion work well.
Usage:
XCTAssert(app.buttons[@"Submit"].exists);
@available(iOS 9, * )
More details on the API
http://kumarsc.github.io/index.html
(Updated till XCode7 Beta 5)

Xcode7 UI Automation

  • 1.
    Xcode 7 UITesting Four new classes One new protocol Three new constants
  • 2.
    XCUIApplication Class: launch(),terminate(), **launchArguments(), launchEnvironment() : No Documentation Resets app instance and provides clean state for each TestCase class Set specific arguments or environments variables at launch. Usage: class DemoTestClass: XCTestCase { override func setUp() { super.setUp() continueAfterFailure = false XCUIApplication().launch() }
  • 3.
    XCUIElement Class: .exists, descendentMatchingType(type:XCUIElementType), childrenMatchingType(type: XCUIElementType), debugDescription Extensions: tap(), pressForDuration(), swipeUp() , typeText() … Representation of UI controls on the views.Elements are described in terms of queries, XCElementQuery. Usage: let app = XCUIApplication() app.navigationBars["All"].buttons["Favorites"].tap()
  • 4.
    XCUIElementQuery Class: .element,.count elementAtIndex(index : UInt) elementMatchingPredicate(predicate: NSPredicate) .allElementsBoundByIndex Helps uniquely locate the UI control to interact with during execution.Provides objects for locating elements which can be chained with other queries. Usage: app.collectionViews.childrenMatchingType(.Cell).elementAtIndex(1).images["AA PLRemoveControl"].doubleTap()
  • 5.
    XCUIDevice Class: sharedDevice() Orientation() Represents aDevice, interface for simulating events involving physical buttons and device state. Usage: XCUIDevice = sharedDevice() UIDeviceOrientation XCUIDevice.orientation(value)
  • 6.
    XCTest Assertion Classes: XCTAssert() XCTAssertEquals() XCTAssertNotNil() SinceXCUI* is extension of XCTest, all existing assertion work well. Usage: XCTAssert(app.buttons[@"Submit"].exists);
  • 7.
    @available(iOS 9, *) More details on the API http://kumarsc.github.io/index.html (Updated till XCode7 Beta 5)