<!--
{
  "availability" : [
    "Xcode: 16.3.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "XCUIAutomation",
  "identifier" : "/documentation/XCUIAutomation/XCUIScreen",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "XCUIAutomation"
    ],
    "preciseIdentifier" : "c:objc(cs)XCUIScreen"
  },
  "title" : "XCUIScreen"
}
-->

# XCUIScreen

A physical screen attached to a device.

```
@MainActor class XCUIScreen
```

## Overview

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

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

```swift
let screenshot = XCUIScreen.main.screenshot()
```

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

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

## Topics

### Device screens

[`mainScreen`](/documentation/XCUIAutomation/XCUIScreen/main)

The current device’s main screen.

[`screens`](/documentation/XCUIAutomation/XCUIScreen/screens)

The current device’s active screens.

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`Sendable`](/documentation/Swift/Sendable)

[`XCUIScreenshotProviding`](/documentation/XCUIAutomation/XCUIScreenshotProviding)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)