appium java-client 8.x - getOrientation method was deprecated- how to check current orientation now?

390 Views Asked by At

Previously it was possible to check device orientation

driver.getOrientation()

In appium java-client 8.3 this method is no longer available. How to check current device orientation now?

2

There are 2 best solutions below

0
On

You will need to cast the driver. From Java Client 8.x.x and Appium 2.0, mobile specific extension commands have been moved to respective drivers.

Basically, if you have initialised the driver like below,

AppiumDriver driver = new AndroidDriver() or
AppiumDriver driver = new IOSDriver(),

Then, cast the driver like below,

((AndroidDriver) driver).getOrientation(); OR
((IOSDriver) driver).getOrientation();

This way, you access the mobile specific extension commands.

0
On

Found it - Mobile specific extensions have been respectively moved to IOSDriver and AndroidDriver.