The below example is just to give you a quick idea of how the to launch or activate apps that are separate from the app under test. The below examples are both for iOS, but a similar rationale would be used for Android; you'd just need to know the bundle IDs or package names of the apps with which you're working.
- iOS: launchApp or activateApp
- Android: startActivity
- bundleIds for iOS: see here, here, or here
- packageNames for Android
For Automated Tests:
As part of your test script, you can do something like close your app, open the camera app, and take a picture.
In the case of the camera, the bundle ID is:com.apple.camera
Some pseudocode would be as follows:
// code to start the app
driver.closeApp(); //closes the current app
driver.activateApp('com.apple.camera'); // Opens Camera app
// some code to press the Camera shutter button
driver.activateApp('com.foo.bar'); // Opens the original app
And if necessary: to press the home button, you can use the mobile: pressButton action like so:
driver.executeScript("mobile: pressButton", ImmutableMap.of("name", "home"));
For Appium Desktop:
Once the session has started, go to actions –> Device & Execute Mobile:
There, you'd enter mobile: activateApp for the command. For the jsonArgument, type {"bundleID": "com.apple.mobilesafari"} or whatever the bundle ID is of the app you'd like to activate:
And then refresh, and your app should be visible: