Many times the application screen has to be rotated to automate any testcase. Most of the applications opens in portrait mode and if there we have to verify something in landscape mode then we cannot rotate the screen manually in the middle to any test. The optimal solution of this issue is that we should set the orientation programmatically after the step we want orientation and again reset the position once the action is completed. There are four orientation provided by the android:
unspecified: The default state
We have to pass the orientation type in the method rotate(org.openqa.selenium.ScreenOrientation orientation) to rotate the screen.
Suppose, we have to rotate the screen in landscape mode from the portrait mode and perform some action and then again rotate the screen back to portrait mode.
//Launch the application
//Perform some desired actions and again switch to portrait mode
//Continue the test
In this way we can rotate the screen as per the requirement.