How to test mobile app in Landscape or Portrait mode using Appium
On This Page Testing Mobile Apps in Landscape and Portrait mode using AppiumJanuary 17, 2026 · 6 min read · Tool Comparison
Mobile apps today are progressively diverse, offering unique features and experiences. Many apps behave otherwise in portrait and landscape modes, impacting useableness and user experience. Manual testing for these orientation can be cumbersome, especially for complex apps. Automated test using Appium simplifies this process and ensures consistent behavior across devices. Integrating with a real device cloud, like BrowserStack, allows try on multiple existent Android and iOS devices without investing in physical ironware. Why Orientation Testing Matters Manual vs Automated Orientation Testing Orientation Testing Methods using Appium Method 1 → Set orientation before test executing Method 2 → Change orientation during test execution This guide explains how to test nomadic apps in landscape and portraiture orientations using Appium, both topically and on BrowserStack ’ s real twist cloud. For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users. is easygoing, since you feature to simply switch these modes by locking/unlocking the “ screen-orientation button ” on the mobile twist. Then hold the device horizontally/vertically which then automatically takes attention of the desired orientation way of the screen. However, for more number of features, screen each of them for landscape and portrait modes manually is inept. Hence, examination mechanization using Appium is required in such cases. To perform Automated Testing of Landscape and Portrait way in, there are two ways ply by Appium which can be utilized. Prerequisites Make sure you have all software installed and running in your scheme. In this example, we will use the ‘ Youtube ’ Android App to try Landscape and Portrait Modes in Appium. By postdate the above example, you can easily change the screen orientation of your device using Appium. For accurate results, it ’ s advisable to make use of tools and increase by a hundred multiplication by testing your app on multiple variation of run systems and different Android and iOS devices., like BrowserStack, provides this platform where you can mix your with K of available real device using. To integrate with BrowserStack, be quiz and postdate the subsequent steps to get the app url. After integration with BrowserStack App Automate, the codification will appear like the below: Video Log Test results can be viewed on formerly the test executing is completed. For any kind of test, results play a key part in debugging and delivering a bug-free user experience. Using BrowserStack App Automate for testing not only allows you access to thousands of real devices across different platforms but also helps you debug easier with a dedicated dashboard to check test results, text, console, and video logarithm along with the screenshots. Clicking on individual trial will yield you a detailed report for each test including steps,, Appium log, executing picture logs, and other details for best debugging of failed tests. With BrowserStack App Automate you can not only ascertain your exam results but share with your team on Slack,, or GitHub for best collaboration and debugging. # 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 test nomadic app in Landscape or Portrait mode using Appium
Overview
Testing Mobile Apps in Landscape and Portrait mode using Appium
Method 1By supply the capability for screen orientation before the test performance
bundle testing; import org.testng.annotations.Test; importation org.openqa.selenium.remote.DesiredCapabilities; import io.appium.java_client.android.AndroidDriver; import java.net.URL; import java.util.concurrent.TimeUnit; significance org.openqa.selenium.ScreenOrientation; public form Switchorientation {@ Test public emptiness test () {try {DesiredCapabilities detonator = new DesiredCapabilities (); caps.setCapability (`` deviceName '', `` My Device ''); //Give your device/emulator name caps.setCapability (`` udid '', `` emulator-5554 ''); // Go to adb location i.e. C: \Users\singe\AppData\Local\Android\Sdk\platform-tools in command prompting and fulfil ‘ adb devices ’ to get udid caps.setCapability (`` platformVersion '', `` 8.1.0 ''); //Give android edition of your gimmick. (Check ‘ about sound ’ section) caps.setCapability (`` appPackage '', `` com.google.android.youtube ''); //provide app software name. Apkinfo can be used or execute dumpsys window window | grep -E ‘ mCurrentFocus ’ dictation in adb shell in cmd in C: \Users\singe\AppData\Local\Android\Sdk\platform-tools caps.setCapability (`` appActivity '', `` com.google.android.apps.youtube.app.WatchWhileActivity ''); caps.setCapability (`` orientation '', `` LANDSCAPE ''); AndroidDriver driver = new AndroidDriver (new URL (`` http: //127.0.0.1:4723/wd/hub ''), detonator); //Create driver object driver.manage () .timeouts () .implicitlyWait (10, TimeUnit.SECONDS); //Implicit wait of 10 seconds driver.quit ();} catch (Exception e) {// TODO Auto-generated catch block e.printStackTrace ();}}}Method 2By utilize “ ScreenOrientation ” method during the test execution
package try; import org.testng.annotations.Test; import org.openqa.selenium.remote.DesiredCapabilities; signification io.appium.java_client.android.AndroidDriver; import java.net.URL; importee java.util.concurrent.TimeUnit; import org.openqa.selenium.ScreenOrientation; public class Switchorientation {@ Test public void test () {try {DesiredCapabilities caps = new DesiredCapabilities (); caps.setCapability (`` deviceName '', `` My Device ''); caps.setCapability (`` udid '', `` emulator-5554 ''); caps.setCapability (`` platformVersion '', `` 8.1.0 ''); caps.setCapability (`` appPackage '', `` com.google.android.youtube ''); caps.setCapability (`` appActivity '', `` com.google.android.apps.youtube.app.WatchWhileActivity ''); AndroidDriver driver = new AndroidDriver (new URL (`` http: //127.0.0.1:4723/wd/hub ''), cap); driver.manage () .timeouts () .implicitlyWait (10, TimeUnit.SECONDS); ScreenOrientation orientation=driver.getOrientation (); System.out.println (`` Currentorientation: '' +orientation); driver.rotate (ScreenOrientation.LANDSCAPE); Thread.sleep (5000); driver.quit ();} haul (Exception e) {// TODO Auto-generated catch block e.printStackTrace ();}}}Testing Landscape and Portrait Modes on Real Devices using Appium with BrowserStack
Method 1 By adding the capability for screen orientation before the test execution
package prove; import java.net.URL; import java.util.List; importation java.util.function.Function; import java.net.MalformedURLException; meaning io.appium.java_client.MobileBy; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.ScreenOrientation; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.DesiredCapabilities; importation org.testng.annotations.Test; public class BrowserStack {public static nothingness main (String [] args) shed MalformedURLException, InterruptedException {DesiredCapabilities caps = new DesiredCapabilities (); // Set your approach certificate caps.setCapability (`` browserstack.user ”, & lt; user-name & gt;); caps.setCapability (`` browserstack.key '', & lt; access-key & gt;); // Set URL of the covering under test caps.setCapability (`` app '', `` bs: //9cc026f23e20d659e525a052e5fdbbe4fea33c24 ''); // Specify device and os_version for testing caps.setCapability (`` device '', '' Samsung Galaxy A52 ''); caps.setCapability (`` os_version '', `` 11.0 ''); // Set other BrowserStack capableness caps.setCapability (`` projection '', `` Maiden Java Project ''); caps.setCapability (`` build '', `` browserstack-build-1 ''); caps.setCapability (`` name '', `` first_test ''); caps.setCapability (`` deviceOrientation '', `` landscape ''); // Initialize the remote Webdriver apply BrowserStack remote URL // and desired capabilities delimitate above AndroidDriver & lt; AndroidElement & gt; driver = new AndroidDriver & lt; AndroidElement & gt; (new URL (`` http: //hub.browserstack.com/wd/hub ''), caps); Thread.sleep (5000); // Invoke driver.quit () after the test is done to depart the window session. driver.quit ();}}Method 2 By using “ ScreenOrientation ” method during the test execution
package examine; importation java.net.URL; import java.util.List; import java.util.function.Function; import java.net.MalformedURLException; importation io.appium.java_client.MobileBy; signification io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.ScreenOrientation; import org.openqa.selenium.WebDriver; significance org.openqa.selenium.remote.DesiredCapabilities; signification org.testng.annotations.Test; public class BrowserStack {public static void main (String [] args) throws MalformedURLException, InterruptedException {DesiredCapabilities cap = new DesiredCapabilities (); // Set your access credentials caps.setCapability (`` browserstack.user '', `` apekshagupta_ZFOdov ''); caps.setCapability (`` browserstack.key '', `` PXpX6gUdTp68RMeQFLGM ''); // Set URL of the application under test caps.setCapability (`` app '', `` bs: //9cc026f23e20d659e525a052e5fdbbe4fea33c24 ''); // Specify twist and os_version for prove caps.setCapability (`` device '', `` Samsung Galaxy A52 ''); caps.setCapability (`` os_version '', `` 11.0 ''); // Set other BrowserStack capabilities caps.setCapability (`` projection '', `` 1st Java Project ''); caps.setCapability (`` build '', `` browserstack-build-1 ''); caps.setCapability (`` name '', `` first_test ''); // Initialise the remote Webdriver use BrowserStack remote URL // and desired capabilities defined above AndroidDriver & lt; AndroidElement & gt; driver = new AndroidDriver & lt; AndroidElement & gt; (new URL (`` http: //hub.browserstack.com/wd/hub ''), caps); ScreenOrientation orientation=driver.getOrientation (); driver.rotate (ScreenOrientation.LANDSCAPE); Thread.sleep (5000); // Invoke driver.quit () fter the tryout is done to quit the window session. driver.quit ();}}Test Results
Related Guides
Automate This With SUSA
Test Your App Autonomously