@mykola-mokhnach
I could see the runAppInBackground command executed twice when putting the app in background for 120 seconds. (Tried 119 seconds as well. It’s behaving in the same way). But When I put the app in background for 115 seconds, it’s executed only once - works as expected.
You could see the adb command adb shell monkey in the logs while appium started executing the runAppInBackground command second time. May I know what is the issue here?
I’ve tried in android device and using latest appium version: 1.11.0. In older versions as well I’ve faced the same issue when increasing the background time.
Put app in background for 120 seconds
driver.runAppInBackground(Duration.ofSeconds(120))
[HTTP] --> POST /wd/hub/session/b8a82cab-0535-434b-b9c6-ea7cb97ee582/appium/app/background
[HTTP] {“seconds”:120}
[debug] [W3C (b8a82cab)] Calling AppiumDriver.background() with args: [120,“b8a82cab-0535-434b-b9c6-ea7cb97ee582”]
[debug] [ADB] Getting focused package and activity
[debug] [ADB] Running ‘/home/anto/Android/Sdk/platform-tools/adb -P 5037 -s ce12171cd031b8050c shell dumpsys window windows’
[debug] [ADB] Pressing the HOME button
[debug] [ADB] Running ‘/home/anto/Android/Sdk/platform-tools/adb -P 5037 -s ce12171cd031b8050c shell input keyevent 3’
TRYING SECOND TIME:
[debug] [AndroidDriver] Activating app ‘x.x.x’ in order to restore it
[debug] [AndroidDriver] Activating ‘x.x.x’ with ‘adb shell monkey -p x.x.x -c android.intent.category.LAUNCHER 1’ command
[debug] [ADB] Running ‘/home/anto/Android/Sdk/platform-tools/adb -P 5037 -s ce12171cd031b8050c shell monkey -p x.x.x -c android.intent.category.LAUNCHER 1’
[HTTP] <-- POST /wd/hub/session/b8a82cab-0535-434b-b9c6-ea7cb97ee582/appium/app/background - - ms - -
[HTTP]
[HTTP] --> POST /wd/hub/session/b8a82cab-0535-434b-b9c6-ea7cb97ee582/appium/app/background
[HTTP] {“seconds”:120}
[debug] [W3C (b8a82cab)] Calling AppiumDriver.background() with args: [120,“b8a82cab-0535-434b-b9c6-ea7cb97ee582”]
[debug] [AndroidDriver] Command stdout: Events injected: 1
[debug] [AndroidDriver] ## Network stats: elapsed time=28ms (0ms mobile, 0ms wifi, 28ms not connected)
[debug] [ADB] Getting focused package and activity
[debug] [ADB] Running ‘/home/anto/Android/Sdk/platform-tools/adb -P 5037 -s ce12171cd031b8050c shell dumpsys window windows’
[debug] [W3C (b8a82cab)] Responding to client with driver.background() result: true
[debug] [ADB] Pressing the HOME button
[debug] [ADB] Running ‘/home/anto/Android/Sdk/platform-tools/adb -P 5037 -s ce12171cd031b8050c shell input keyevent 3’
[debug] [AndroidDriver] Activating app ‘x.x.x’ in order to restore it
[debug] [AndroidDriver] Activating ‘x.x.x’ with ‘adb shell monkey -p x.x.x -c android.intent.category.LAUNCHER 1’ command
[debug] [ADB] Running ‘/home/anto/Android/Sdk/platform-tools/adb -P 5037 -s ce12171cd031b8050c shell monkey -p x.x.x -c android.intent.category.LAUNCHER 1’
[debug] [AndroidDriver] Command stdout: Events injected: 1
[debug] [AndroidDriver] ## Network stats: elapsed time=23ms (0ms mobile, 0ms wifi, 23ms not connected)
[debug] [W3C (b8a82cab)] Responding to client with driver.background() result: true
[HTTP] <-- POST /wd/hub/session/b8a82cab-0535-434b-b9c6-ea7cb97ee582/appium/app/background 200 121545 ms - 14