Skip to content

feat: Expose device orientation via /wda/deviceOrientation#1162

Open
anton-yereshchenko wants to merge 2 commits into
appium:masterfrom
anton-yereshchenko:features/add_deviceOrientation_endpoint
Open

feat: Expose device orientation via /wda/deviceOrientation#1162
anton-yereshchenko wants to merge 2 commits into
appium:masterfrom
anton-yereshchenko:features/add_deviceOrientation_endpoint

Conversation

@anton-yereshchenko

@anton-yereshchenko anton-yereshchenko commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Adds a new GET /wda/deviceOrientation endpoint that returns the physical device orientation.

Motivation

The existing GET /orientation reports the app's interface orientation (application.interfaceOrientation) and collapses everything to PORTRAIT/LANDSCAPE. This new endpoint exposes the raw physical UIDeviceOrientation (XCUIDevice.orientation), which is useful when an app locks its UI but the device is physically rotated, and preserves the finer-grained values (landscape left/right, portrait upside-down).

Changes

  • Add GET /wda/deviceOrientation route (with and without session)
  • Add fb_deviceOrientation to the XCUIDevice (FBRotation) category, mapping UIDeviceOrientation to the WebDriver orientation string (same switch style as the existing FBInterfaceOrientationFromDeviceOrientation)
  • handleGetDeviceOrientation: simply delegates to XCUIDevice.sharedDevice.fb_deviceOrientation
  • Return "UNKNOWN" for non-interface orientations (face up/down/unknown)
  • Add integration tests for portrait / landscape-left / landscape-right

How to test

GET /wda/deviceOrientation → returns the current device orientation (PORTRAIT, LANDSCAPE, UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT, UIA_DEVICE_ORIENTATION_PORTRAIT_UPSIDEDOWN, or UNKNOWN).

Comment thread WebDriverAgentLib/Commands/FBOrientationCommands.m Outdated
@property (strong, nonatomic, readonly) NSDictionary *fb_rotationMapping;

/**
The current physical device orientation represented as a WebDriver orientation string,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any reason to limit possible values by only these constants? Lets have a new string mapping that reflects properly what XCUIDevice.sharedDevice.fb_deviceOrientation returns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants