Maximum timeout for background

Hey guys,
I have a question regarding a test case, which I have to automate for a native mobile app.
The requirement is to open the app on the mobile device, to log in, to minimize the app for at least 20 mins and to bring it foreground again after this time.
However, I am not quite sure how to do it… I am thinking of using:
await driver.background(-1);
await driver.pause(1500000);
await driver.activateApp(’*****’);

I am testing the app on a device in Sauce Labs and I have the concern whether the session would be killed after some time, if there is no interaction with the device. I think Sauce Labs has a limit of 90 secs and after that terminate the session.
Do you know what is the maximum time for the .background() function? Should I use the .pause() function?
Have you encountered similar situation or do you have any suggestions?
I am using Appium, WebdriverIO framework and TypeScript.

Deprecated An integer: how long, in seconds, to background the app for. -1 means to deactivate the app entirely

My experience is that the app is not deactivated, but is running in the background indefinitely. I have run locally in the background for up to 5 minutes. Not sure I would run in background for 20 minutes on any device farm, (seems like the kind of test I would only run locally to save on vendor time) but YMMV.

https://appium.io/docs/en/commands/device/app/background-app/

Thank you for the reply!

I think this test case couldn’t be automated. The Sauce Labs supports idleTimeout up to 15 mins for Virtual Devices only, so this does not work in my case.

However, do you know if there is a way to “fake” expiration of the a user token?
The user token in out app is active up to 20 minutes and after that the session expires. If there is a way to shorten the token time below 5 minutes, this would be a great workaround.

To me it does not look like a valid scenario to automate. 20 minutes is too much - many things might happen within this time, that could affect the automated script. Consider preparing a backdoor with shorter expiration timeout if this scenario needs to be automated.

Agree with @mykola-mokhnach. Ask developers if they can provide tokens that expire in a shorter time period.

if you really want to test REAL 15 min -> make it in following way:

  1. send app into background with “-1” -> https://appium.io/docs/en/commands/device/app/background-app/ -> “-1 means to deactivate the app entirely.”
  2. in loop ping driver to prevent it shut down with some command. I do it with:
// repeat in loop for 15 min
  new AppDriver(driver).getContext()
  // sleep now 30 sec
  1. now activate your app and continue