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.


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