Appium-Cookbook
  • Appium
  • Set-up
    • Installation
    • java-client
  • Recipes
    • Actions
    • Keyboard Events
    • Swipe Actions
    • DragNDrop
    • Orientation
    • Assertions
Powered by GitBook
On this page
  • To rotate screen to LandScape mode:
  • To rotate screen to Portrait mode:

Was this helpful?

  1. Recipes

Orientation

To rotate screen to LandScape mode:

Create a reusable function using DeviceRotation class

helper.java
  public static void testLandscapeRightRotation() {
        DeviceRotation rotation = new DeviceRotation(0, 0, 90);
        driver.rotate(rotation);
        assertEquals(driver.rotation(), rotation);
    }

To rotate screen to LandScape mode, import above function from helper.java class

test.java

$ helper.testLandscapeRightRotation();

To rotate screen to Portrait mode:

Create a reusable function using DeviceRotation class

helper.java
  public static void testPortraitRightRotation() {
        DeviceRotation rotation = new DeviceRotation(0, 0, 180);
        driver.rotate(rotation);
        assertEquals(driver.rotation(), rotation);
    }

To rotate screen to Portrait mode, import above function from helper.java class

test.java

$ helper.testPortraitRightRotation();
PreviousDragNDropNextAssertions

Last updated 5 years ago

Was this helpful?