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.

Beta
protocol XCUIScreenshotProviding

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

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software