I am trying to run 2 different tests on 2 different emulators parallelly. But my execution halts on 1 device as soon as the test on other device is complete. I am using the below driver setup code

capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("VERSION", platformVersion);
capabilities.setCapability("udid", deviceName);
capabilities.setCapability("app", "app.apk");
capabilities.setCapability("appPackage", "xxx");
capabilities.setCapability("appActivitiy", "xxx.HomeActivity");
capabilities.setCapability("systemPort", systemPort);
driver = new AndroidDriver(new URL(""), capabilities);

And below is my testNG.xml file

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Parallel Tests" parallel="tests" thread-count="2">
    <test name="Android native app test on Android 12">
        <parameter name="platformVersion" value="12"/>
        <parameter name="deviceName" value="emulator-5554"/>
        <parameter name="systemPort" value="6666"/>
            <class name="LoginTest" />
    <test name="Android native app test on Android 10">
        <parameter name="platformVersion" value="10"/>
        <parameter name="deviceName" value="emulator-5556"/>
        <parameter name="systemPort" value="8666"/>
            <class name="SignUpTest" />

I get the following exception

org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?

And sometimes this exception as well

org.openqa.selenium.NoSuchSessionException: A session is either terminated or not started

2 Answers 2



What is the problem & why its happening?

  • Your test on 1 device gets halted because, I can see how you have initialise your driver static using port 4723
    driver = new AndroidDriver(new URL(""), capabilities);

Solution :

  • When you want to execute tests in parallel you should :
    • Create no. of driver instances equal to the same no. of devices to perform tests
    • You should have different port for each driver instance
    • Example :
      1. If I want to run tests on 2 devices
      2. Driver should be initialise separately with separate port number
  // Driver 1: 
  driver1 = new AndroidDriver(new URL(""), capabilities);

  //Driver 2
  driver2 = new AndroidDriver(new URL(""), capabilities);

Note - To run tests in parallel, you do not need to run two separate instances of appium server. Parallel support has been implemented after version 1.5 onwards


The error you're encountering suggests that the sessions for both devices were not created or were terminated before the tests were executed. Here are a couple of things to check:

  1. Verify that the URL "" is accessible and the Appium server is running.
  2. Make sure that the ports (6666 and 8666) specified in the systemPort capability are not being used by any other process and are accessible.
  3. Try running the tests on a single device first to ensure that everything is working correctly before attempting to run them in parallel.
  4. When using Appium in parallel, it is also important to ensure that each device has a unique system port, UDID, and appPackage/appActivity capabilities.

If the above steps do not resolve the issue, try adding some logging statements in your code to track the session status, and to see if any exceptions are thrown while creating the sessions.

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.