A physical screen attached to a device.


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 = { screen in
    return screen.screenshot()


Device Screens

class var main: XCUIScreen

The current device’s main screen.

class var screens: [XCUIScreen]

The current device’s active screens.


Inherits From

See Also


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.