Interactions

Common gestures and input actions in XCUITest.

Tap, type, swipe

swift
// Tap
app.buttons["Submit"].tap()
app.buttons["Submit"].doubleTap()

// Type text
app.textFields["email"].tap()
app.textFields["email"].typeText("[email protected]")

// Clear text and retype
let field = app.textFields["email"]
field.tap()
field.press(forDuration: 1.0) // show select all menu
app.menuItems["Select All"].tap()
field.typeText("[email protected]")

// Swipe
app.swipeUp()
app.swipeDown()
app.tables.cells.element(boundBy: 0).swipeLeft()

// Scroll to element
app.tables.cells["Settings Cell"].swipeUp()

// Long press
app.cells["message"].press(forDuration: 1.5)

// Pinch / zoom
app.maps.element.pinch(withScale: 2.0, velocity: 1.0)