Search code examples
appiumappium-androidpython-appium

Appium closing app, leaving background process


I have two drivers, one for my app and one for Chrome.

The flow is like so:

  1. Start the app driver, set up the app (app starts background process).
  2. Start the Chrome driver, do some stuff there and quit this driver.

But what I actually want to do is this:

  1. Start the app driver, set up the app (app starts background process).
  2. Close this app, but leave the background process running
  3. Start the Chrome driver, do some stuff there and quit this driver.
  4. Open back up the app which I have closed in step 2

Quitting the driver (driver.quit()) is obviously not an option, since this also kills the background process. Same as with (driver.close_app()).

I was thinking about doing this via UI, by simply clicking the "Recent Button" and swiping up on my app, but how would I then get back the app?

My question: Is it possible to close the app without killing the background process, if so - how?


Solution

  • After asking in the Appium Forum the solution is as follows:

    Put the app into background for an indefinite amount of time:

    driver.background_app(-1)
    

    and activate it once you need it again:

    driver.activate_app("app.id")