> For the complete documentation index, see [llms.txt](https://vinayak-titti.gitbook.io/appium-cookbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vinayak-titti.gitbook.io/appium-cookbook/recipes/orientation.md).

# Orientation

## To rotate screen to LandScape mode:

Create a reusable function using DeviceRotation class &#x20;

{% code title="helper.java" %}

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

{% endcode %}

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 &#x20;

{% code title="helper.java" %}

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

{% endcode %}

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

```
test.java

$ helper.testPortraitRightRotation();
```
