Contents

XCUIScreen

A physical screen attached to a device.

Declaration

@MainActor class XCUIScreen

Overview

Call the screenshot() method on an XCUIScreen instance to capture a screenshot of its current UI state. The XCUIScreenshotProviding protocol adds this method to XCUIScreen.

You can take a screenshot of the current device’s main screen using the following code:

let screenshot = XCUIScreen.main.screenshot()

You can take a screenshot of every screen on the current device using the following code:

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

Topics

Device screens

See Also

Screenshots