Change screen orientation

Appium allows you to change the screen orientation of your iOS and Android devices.
You can choose to either change the orientation at the start of the test or during a test.

Set screen orientation at the start of your test

desired_caps = {
    'orientation': 'LANDSCAPE'
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("orientation", "LANDSCAPE");
$capabilities = new DesiredCapabilities();
$capabilities->setCapability("orientation", "LANDSCAPE");
desired_cap = {
	'orientation': 'LANDSCAPE'
var capabilities = {
	'orientation': 'LANDSCAPE',
DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability("orientation", "LANDSCAPE");

Set screen orientation during a test

@driver.rotation = :landscape
((AppiumDriver) driver).rotate(ScreenOrientation.LANDSCAPE);
// not yet supported
driver.orientation = "LANDSCAPE"
driver.Orientation = ScreenOrientation.Landscape;