This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
14 / 31
Feb 2018

This will also send the app in the background then will launch, but he needs to perform some operations in the app, don’t want to relaunch the app

@Telmo_Cardoso - Yeah I am agree with you, but I don’t think there is way to go homescreen if we don’t have back button in the application. we have to either use launchApp() or runAppInBackground(duration) and both of them sends the app in the background.

one more thing runAppInBackground(duration) method, persists the last state of the application.

Ah sorry. I was reading device home screen :smiley: not app home screen… It’s what we get for reading in diagonal.

Then its easier, he just needs to make the steps any normal user would do to go back to app home screen like you told.

Hi guys. thanks for your answers.
Actually I mean device home screen.
The scenario is that - I’m doing some actions in my app then I need to background my app and do some actions in device home screen after that I need to go back to my app, so, I can do all but going to the device home screen.
I will check your suggestion to do:
driver.runAppInBackground(Duration.ofSeconds(-1));

with XCuiTest driver you can interact with native iOS,yes. I use it to enable/disable WiFi, mobile data, location, permissions, etc.

is there any possible way that we can tap on the home button of the ios device ?
I think after tapping the home button, we can perform native ios operations and can again launch the app by providing bundle id.

on real ios devices thats not possible. For simulator I think there are scripts around to do that. But if you just want to go to homescreen you dont need to tap the home button, just use the above command.

I have one doubt, above method will send the app in the background, but only for particular period of time which we will provide and in the process of sending app into background and then launching again after the provided time, how we will perform actions on homescreen between the process?

The -1 in the duration makes that it doesn’t goes back to app automatically :wink:

Test it:

driver.runAppInBackground(Duration.ofSeconds(-1));

This change is based on appium/appium-xcuitest-driver#381, which makes possible to minimize the application under test and then return to iOS springboard (emulates clicking Home button).

From https://github.com/appium/java-client/pull/59318

12 days later

Hi After using driver.runAppInBackground(Duration.ofSeconds(-1));, how to return to the same app. Can you please help

If you are using latest Appium/Java Client use:

driver.activateApp(bundle_id);
8 months later

Hi how can I do the same process for Android,

driver.runAppInBackground(Duration.ofSeconds(-1));
is working for me to go Homepage but how can I back from home to my app in android? thanks