How to test app in Landscape or Portrait Mode using XCUITest
On This Page Why to test apps in Landscape or Portrait?June 10, 2026 · 4 min read · Testing Guide
iOS apps are developed to serve various determination from entertainment to eCommerce. At times a certain app/feature cater better vision and compatibility in certain screen orientations, viz Portrait and Landscape. While the nonpayment screen orientation for a mobile application is Portrait, in certain lawsuit like watching movies and playing games, the screen orientation makes a difference in the user experience. Based on the coating and its use cause, screen orientation can be altered to serve the purpose and provide best user experience. Hence, it should be tested for the application before making a release. Why Orientation Testing Matters How to Switch Orientation in XCUITest Validating UI Orientation This guide demonstrate how to programmatically switch orientations and validate UI responsiveness using XCUITest (iOS). In Mobile devices, its useful to view contents of the app in landscape and portrait modes depend upon usages and ease of accessing for users. Most mobile users use apps and their devices on both landscape and portrait mode. Hence it becomes important to test our apps too on both orientations. It is noteworthy, that you are setting and dealing with the device orientation, which indirectly shall revolve the apps screen as well and display the app on mandatory orientations. To simply bring the current interface orientation of an iOS device, you can use the below command: where, orientationis an in-built variable of classUIDevicewhich returns the current device orientation in tests. This consist of instance properties such as, (each regress Boolean value) For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users. isPortrait For Example, For Example, An app can be set to landscape or portrait orientation, by using one of the four twist revolution options: Let us appear into each of the above in item with examples of code snippets in Swift language. It pose the device on portrait mode vertically having devices ’ home button on the bottom For Example, It pose the device on portrait modality vertically having device ’ abode button on the top For Example, It sets the gimmick on landscape mode horizontally having device ’ s home push on the right Example: It fix the device on landscape mode horizontally hold device ’ s habitation push on the left For example, While, you can configure our tests to run on landscape as well as portraiture mode from test book itself, we can also configure the same on CI shape file while integrating with. For Landscape orientation: For Portrait orientation: Conclusion While testing mobile covering, it is always advocate to test on real devices, to check that the are direct into consideration. Testing on emulator and simulator does not provide accurate results as it just mimics the device environs, dismiss existent world scenario. Hence tests like running apps in Landscape or Portrait mode should be make on existent devices only. allows access to a large fleet of Android and iOS nomadic device, so lots so that. On This Page # Ask-and-Contributeabout this topic with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.How to screen app in Landscape or Portrait Mode using XCUITest
Overview
Why to test apps in Landscape or Portrait?
How to test if an app is in Landscape or Portrait?
XCUIDevice.shared.orientation
var device = XCUIDevice.shared.orientation print (device.isPortrait) // returns true or false
isLandscape
var device = XCUIDevice.shared.orientation print (device.isLandscape) // returns true or mistaken
How to set and test the device in Landscape or Portrait?
.portrait
var device = XCUIDevice.shared.orientation device = .portrait // device under test is set to portrait XCTAssertTrue (device.isPortrait) // tests if device is in portrayal
.portraitUpsideDown
var device = XCUIDevice.shared.orientation device = .portraitUpsideDown XCTAssertTrue (device.isPortrait) // tests if device is in portraiture
.landscapeLeft
var device = XCUIDevice.shared.orientation device = .landscapeLeft XCTAssertTrue (device.isLandscape) // tests if device is in landscape
.landscapeRight
var gimmick = XCUIDevice.shared.orientation device = .landscapeRight XCTAssertTrue (device.isLandscape) // tests if twist is in landscape
How to run XCUITest in Landscape or Portrait with BrowserStack integration?
roll -u `` username: accesskey '' \ -X POST `` https: //api-cloud.browserstack.com/app-automate/xcuitest/v2/build '' \ -d ' {`` deviceOrientation '': `` landscape '', `` devices '': [`` iPhone 8 Plus-11.0 ''], `` app '': `` bs: //f5L3azt9pLzE995f49376eb1fa3c284dc321f8d '', `` testSuite '': `` bs: //6eb1fa3c284ddbe9971b2d1aee0d52943b9c081 ''} ' \ -H `` Content-Type: application/json ''curl -u `` username: accesskey '' \ -X POST `` https: //api-cloud.browserstack.com/app-automate/xcuitest/v2/build '' \ -d ' {`` deviceOrientation '': `` portrait '', `` devices '': [`` iPhone 8 Plus-11.0 ''], `` app '': `` bs: //f5L3azt9pLzE995f49376eb1fa3c284dc321f8d '', `` testSuite '': `` bs: //6eb1fa3c284ddbe9971b2d1aee0d52943b9c081 ''} ' \ -H `` Content-Type: application/json ''Related Guides
Automate This With SUSA
Test Your App Autonomously