Interacting with another app
Most of the time, when we test a mobile application, it requires interaction with another app. For example, an app might need integration with the Contacts app or the SMS app. Sometimes, while testing, we might need to simulate the geo location, which can be done via an external app installed on the device/emulator (or it can even be done using Android adb
commands).
When we start an Appium session for testing, generally it is tied to an app as we are passing the app
parameter in the desired capabilities, so we can't really pass two apps in the desired capabilities. If we recall our code, we are using this line:
capabilities.setCapability("app", "/Users/nishant/Development/HelloAppium/app/quikr.apk");
One way to switch between the apps is when we know the target app's package name and activity name. Android driver exposes a method, startActivity(Activity activity)
, which basically takes an activity as input and starts it. So, a sample code snippet to start the Contacts...