How do I open messaging app when test case is running for any other app.

Need to fetch OTP from messaging app during a test case is running for my android app. I have tried to create new instance RemoteWebDriver for Appium server with messaging app capabilities.

//Confirm OTP Submission driver.findElement(By.id("btnConfirm")).click();

//Open messaging app to fetch OTP.
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("appPackage", "com.android.mms");
cap.setCapability("appActivity", "com.android.mms.ui.ConversationList");
driver = new RemoteWebDriver(new URL(""), cap);

But, above code is not working and got error -

A new session could not be created. (Original error: Requested a new session but one was in progress)

I am using testNG, Appium, Eclipse on Windows7.

1 Answer 1


currently Appium doesn't support for multiple session, so you cannot create another instance of driver to start another app (I hope the next release of Appium will support it).

but alternatively, you can start another app while Appium the AUT still running. by starting it using ADB command. for example if you want to start the messaging app, you can start it using:

adb shell monkey -p com.android.mms 1

Just implement it on your test code. For example in java:

public static void startMessaging() {
    ProcessBuilder pb = new ProcessBuilder("adb", "shell", "monkey", "-p","com.android.mms", "1");
    Process pc = pb.start();

I hope it will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.