I'm Shoban
Consultant
BabuShoban
in/BabuShoban
@BabuShoban
What is XCUITest?
Downsides
My first Test
XCUITest API’s
Waiting Strategy
Gestures
Parallels
CI Integration
Q & A
import XCTest
class MyFirstTestcase: XCTestCase {
let app = XCUIApplication()
override func setUp() {
super.setUp()
continueAfterFailure = false
app.launch()
}
func testExample() throws {
app.staticTexts["View Schedule"].tap()
app.buttons["Finish Game"].tap()
XCTAssert(app.alerts["You won!"].exists)
app.alerts["You won!"].buttons["Awesome!"].tap()
}
override func tearDown() {
app.terminate()
}
}
XCUIApplication
XCUIElement
XCUIElementQuery
XCUIApplication
XCUIElementQuery
XCUIElement
XCUIElementQuery
XCUIApplication
Launch App
Find Elements on Screen
Interact elements on Screen
Assert expectation
Kill App
XCUIElement.waitForExistence(timeout:)
XCTestCase.expectation(for:evaluatedWith:handler:)
XCTestCase.waitForExpectations(timeout:handler:)
Thread.sleep(forTimeInterval:)
expectation(
for: NSPredicate(format: "exists == true"),
evaluatedWith: app.buttons["identifier"],
handler: .none
)
waitForExpectations(timeout: 5)tap()
doubleTap()
twoFingerTap()
tap(withNumberOfTaps:numberOfTouches:)
press(forDuration)
swipeLeft(), swipeRight(), swipeUp(), swipeDown()
pinch(withScale:velocity:)
rotate(_: withVelocity:)
adjust(toPickerWheelValue: 1)
adjust(toNormalizedSliderPosition: 0.5)