iOS [iPhone] how to put active app in background and perform some action while app is in background

iOS [iPhone] how to put active app in background and perform some action while app is in background. Action here refers to changing some settings or accessing some other app.

real device or Simulator?

I am using real device. Iphone6.

on real device you will not be able to do anything with another app.

So is there any way to do with Simulator?

Settings yes. Another app did not try.

Can you paste a code snippet. I did give a try but I was not able to perform any action while my app is in background.

how to press home key:

public void pressHomeButton() {
    try {
        String[] args = {"osascript", "-e", "tell application \"System Events\" \n tell application \""+simulatorAppName()+"\" to activate \n tell application \"System Events\" to keystroke \"h\" using {command down, shift down} \n end tell"};
        Process process = Runtime.getRuntime().exec(args);
        BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(process.getErrorStream()));
        String lsString;
        while ((lsString = bufferedReader.readLine()) != null) {
        try{Thread.sleep(200);}catch (Exception e1){}
    } catch (Exception e) {}

tap on settings icon:

((AppiumDriver) driver).tap(1, driver.findElements(“Settings”)).get(0), 200);

As far as not supported any more use another way.

1 Like

Thanks Aleksei for respone!
I will try this out.


sorry for bump on old thread, but it would be good for community to know that now it is possible to go to background in iOS:


After going to background, I can easily now go to settings and change whatever I need much more quickly than with my old “trick”

Was added in java-client in here:

Ok thanks for the information. Then this will be easy to do.

1 Like