it helps some times Add android:configChanges="keyboardHidden|orientation" to your activity in manifest file. This will avoid re-creation of activity on orientation of the device changed. Overide onConfigurationChanged in your activity to handle orientation change manually if any changes need to be done.
I hope this helps . I am using UIAUTOMATOR for doing uiautomation for android 5.0.1 version.While i am clicking on device screenshot option in UIAUTOMATOR getting this error Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Permission denied.Can anyone guide me what might be the reason for this? , I did the below steps because my device is rooted.
How to verify xpath in real android device using uiautomator like 22571267
This might help you You can use appium inspector for getting Exact xpath or id for the selected node You can even try tap,sendKeys to test your xpath. Recorder facility Inspector to inspect each individual element like chrome inspector
How to switch on wifi in uiautomator test case in android device?