Is it possible to switch between iOS applications while testing?

Dear Experts,

I have a question. Is it possible to switch between iOS applications while testing?

For example:
I want to move my iOS application under test in the background, open any other application in the simulator and then open my iOS application again. Kindly advice.

Thanks in advance

Finally got it working for iOS.

System.out.println("swap app test");

//1. Launch the app that you are testing.

//2. Prep for the app to swap (here it's the Photo app) and back to your app.
String PHOTOS_BUNDLE_ID = "com.apple.mobileslideshow"; //this is standard bundle id

// For those using Xcode >=7: select your target and click the  *General*  tab.  
//*Bundle Identifier*  is found under  *Identity*.
String BUNDLE_ID = "com.example.apple-samplecode.UICatalog"; //

//3. Launch the Photo app.
HashMap args = new HashMap<>();
args.put("bundleId", PHOTOS_BUNDLE_ID);
iosDriver.executeScript("mobile: launchApp", args);

Thread.sleep(1000); //wait for 1000 milll.sec

//4. Swap back to your test app.
args.put("bundleId", BUNDLE_ID);
iosDriver.executeScript("mobile: activateApp", args);

Sources:
https://stackoverflow.com/questions/8873203/how-to-get-bundle-id
https://www.headspin.io/blog/switching-between-ios-apps-during-a-test

I hope you will find it useful.

1 Like