Hi guys!
I’ve faced quite interesting issue.
I need to set quite long sleep during the test like over 1 hour long or get app to background.
The problem is whenever phone is locked (or simply screen get black) it is seems that there is no possibility to:
Unlock/Active the phone and run again (from last acitivity) app to foreground.
I have tried with Thread.sleep (yes I know it is not the best solution) and with moving app to background.
Result is always the same:
Moving app to background result:
driver.runAppInBackground(Duration.ofSeconds(x));
[debug] [ADB] Found package: ‘debug’ and fully qualified activity name : ‘com.app.activity’
[debug] [MJSONWP] Responding to client with driver.background() result: null
Sleep try:
Thread.sleep(x);
button.click();
[UiAutomator] UiAutomator exited unexpectedly with code 0, signal null
[debug] [UiAutomator] Moving to state ‘stopped’
[Logcat] Logcat terminated with code 0, signal null
[debug] [AndroidDriver] Shutting down Android driver
[Appium] Closing session, cause was ‘UiAUtomator shut down unexpectedly’
[Appium] Removing session ‘id’ from our master session list
The problem is that this API is good in theory , practically , 50% of the time it doesn’t really work , the app / device is being stuck from time to time
not sure what newCommandTimeout with 0 does But just use a value above the one you plan to be without sending commands to Appium server.
I dont know where that NoHttpResponseException come from… but if you sure that’s no problem with cable connection, then you can try instead of placing tests in idle for 1 hour, just send a driver.getPageSource every 5 minutes or so, to keep connection “alive”.
I never had any problem when app is on background, although I also never tested so much time.
With 0 it is my mistake. It should be very long duration(in my case).
NoHttpResponseException came always after ~25 minutes of keeping app in background.
I will notcie You if I find out some solution
Thank You!