Class

XCUIScreen

A physical screen attached to a device.

Overview

Call the screenshot() method on an XCUIScreen instance to capture a screenshot of its current UI state. This method is added to XCUIScreen by the XCUIScreenshotProviding protocol.

Listing 1

Taking a screenshot of the current device's main screen.

let screenshot = XCUIScreen.main.screenshot()
Listing 2

Taking a screenshot of every screen on the current device.

let allScreenshots = XCUIScreen.screens.map { screen in
    return screen.screenshot()
}

Topics

Device Screens

class var main: XCUIScreen

The current device's main screen.

class var screens: [XCUIScreen]

The current device's active screens.

Relationships

Inherits From

See Also

Screenshots

class XCUIScreenshot

A captured image of a screen, app, or UI element state.

protocol XCUIScreenshotProviding

A type that can provide a screenshot of its current UI state.