To handle mobile device orientation in Appium, you can use the
rotate()
method to change the device orientation to landscape or portrait mode. Here are some steps to handle mobile device orientation in Appium:
1. Identify the Device Orientation : Use the
getOrientation()
method to identify the current device orientation:
const orientation = await driver.getOrientation();
console.log(orientation);?
The output will be either '
portrait
' or '
landscape
'.
2. Rotate the Device Orientation : Use the
rotate()
method to change the device orientation to landscape or portrait mode:
await driver.rotate(90); // rotate to landscape mode
await driver.rotate(0); // rotate back to portrait mode?
By using the
rotate()
method, you can handle mobile device orientation in your Appium test scripts and make them more comprehensive and reliable.