Appium change mobile device AutoRotate option into Portrait mode automatically

Hello guys,

I have faced a critical issue while changing orientation of application.
I have used driver.rotate() method to change orientation from portrait to landscape mode which is working fine but once i performed any action in landscape mode it is observed that AutoRotate option of mobile device change to Portrait. Due to this issue i’m not able to change application orientation from Landscape to Portrait mode by driver.rotate().

Please guys help me with this issue.

Thanks in advance.

Does it work if you do the same manually? Is it not app issue?
Because it looks strange that you can rotate to landscape but cant return to portrait

Yeah its working absolutely fine when i’m doing it manually. This issue only occurs when appium executing automation test on android app. When rotate() function change the orientation of app from portrait to landscape with performing any action on the app & again try to rotate it from landscape to portrait it is observed that automatically mobile orientation option change to portrait mode.

Steps :

  1. Open android application.
  2. Change the orientation from portrait to landscape.
  3. Perform some action on the app in landscape mode.
  4. Now again try to change the orientation from landscape to portrait with the help of rotate() function.

After that i 'm not able to perform anything on my app & my test script is blocked. Then i checked the mobile option of changing orientation & it was changed to portrait.

please help me!

Thanks in advance

Guys please help me with this issue!!

Using Real Device : Nexus 5
Android Version : Marshmallow 6.0.1