<!--
{
  "availability" : [
    "Xcode: 16.3.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -"
  ],
  "documentType" : "symbol",
  "framework" : "XCUIAutomation",
  "identifier" : "/documentation/XCUIAutomation/XCUIDevice/orientation",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "XCUIAutomation"
    ],
    "preciseIdentifier" : "c:objc(cs)XCUIDevice(py)orientation"
  },
  "title" : "orientation"
}
-->

# orientation

The orientation of the device.

```
var orientation: UIDeviceOrientation { get set }
```

## Discussion

To simulate a change in the physical orientation of a device under test, set the value of the [`orientation`](/documentation/XCUIAutomation/XCUIDevice/orientation) property for the shared [`XCUIDevice`](/documentation/XCUIAutomation/XCUIDevice) object to one of the <doc://com.apple.documentation/documentation/UIKit/UIDeviceOrientation> constants UIKit defines. This impacts the <doc://com.apple.documentation/documentation/UIKit/UIDevice/orientation> property UIKit uses to identify a device’s physical orientation. These constants aren’t tied directly to the orientation of your app’s user interface. The example below sets the device orientation to landscape right:

```swift
XCUIDevice.shared.orientation = .landscapeRight
```

Set the property once in your test fixture’s setup or intialization code to set an orientation for all the test methods in that fixture.

Available in iOS.

---

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)