Background mode function

I’m writing a test for my android app.

In the test I am pushing the app to background mode for x seconds and pulling it back using:


The test runs just fine, it pushes the app for background mode for x seconds and return to foreground.
The only problem is -> after pulling back the app, it waits/freezes for a few seconds and only then continue to the next test.

Is that a common problem? and if so is there a alternative solution?

I tried using adb command to push the app for background mode–> adb shell input keyevent 3
but i couldn’t find a command for pulling to foreground mode.

this “driver.runAppInBackground(1);” this will also return your app into foreground but wrap it with try catch.