# Has anyone successfully run test scripts parallel in two or more Android devices?

**URL:** <https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532>\
**Category:** Support\
**Created:** [January 23, 2015, 12:16am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532 "2015-01-23T00:16:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gualber98](https://discuss.appium.io/user_avatar/discuss.appium.io/gualber98/32/5245_2.png) [@gualber98](https://discuss.appium.io/u/gualber98)\
**Post date:** [January 23, 2015, 12:16am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/1 "2015-01-23T00:16:36Z")

</div>

**Question**  
I have search many forums, read many post but I have not found one that has successfully run parallel test scripts in multiple Android devices or emulator. \> Is this is possible? (I think it should be so far I cannot find a solution)

**What I have done so far**  
**1- I have tried:** running parallel test scripts (using Testng) by creating two instances of appium server each with different port, udid, and bootport. I setup the capabilities to match the corresponding instance and it does get executed but NOT parallel.

RESULTS:  
The test fails because of the following two reason: I notice that reason 1 only happens once when I fresh start the appium instances, the remainder of time fails on reason 2.

–1 - First it fails because one of the two appium instance will throw the following error:

> info: Starting App  
> info: [debug] Attempting to kill all ‘uiautomator’ processes  
> info: [debug] Getting all processes with ‘uiautomator’  
> info: [debug] executing cmd: /Applications/adt-bundle-mac-x86\_64-20140624/sdk/platform-tools/adb -s 9a588123 shell “ps ‘uiautomator’”  
> info: [debug] No matching processes found  
> info: [debug] Running bootstrap  
> info: [debug] spawning: /Applications/adt-bundle-mac-x86\_64-20140624/sdk/platform-tools/adb -s 9a588123 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap  
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION\_STATUS: numtests=1  
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION\_STATUS: stream=  
> info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:  
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION\_STATUS: id=UiAutomatorTestRunner  
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION\_STATUS: test=testRunServer  
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION\_STATUS: class=io.appium.android.bootstrap.Bootstrap  
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION\_STATUS: current=1  
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION\_STATUS\_CODE: 1  
> info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724  
> info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready  
> info: [debug] [BOOTSTRAP] [debug] Loading json…  
> info: [debug] Waking up device if it’s not alive  
> info: [debug] Pushing command to appium work queue: [“wake”,{}]  
> info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.  
> **\> error: Unhandled error: Error: read ECONNRESET**  
> at errnoException (net.js:905:11)  
> at TCP.onread (net.js:559:19) context: [POST /wd/hub/session {“desiredCapabilities”:{“appActivity”:“com.core.android.activities.MainActivity”,“appPackage”:“com.core.android”,“platformVersion”:“4.4”,“appWaitPackage”:"com.core.]

2- Second, only one test will gets executed (sometimes in device A or sometimes in device B) in one appium instance and the second instance just halts. Sometimes device A will start running for a few seconds and once device B starts it will halt device A or vise versa.

**2- I have tried:** running appium in Selenium Grid node; I am able to register two distinct appium server node in Grid hub, but once I again I CANNOT get it to run parallel

RESULT:  
The reason it fails is the same as previous reasons, either one Appium instance will halt while the other runs or sometimes even throws a new error that I cannot reproduce. One thing for sure Appium is very unstable trying to run two devices at the same time.

**3. What else I have tried:**  
I have tried using different devices (nexus, samsung, amazon, LG, motorola …). run locally and remotely. I just CANNOT get it to work.

**What I need**  
Your help. Can some one respond **if only you** have successfully run parallel scripts on multiple devices. Can this be done??

---

<div class="post-metadata">

**Author:** ![karthik\_holla](https://discuss.appium.io/user_avatar/discuss.appium.io/karthik_holla/32/7807_2.png) [@karthik\_holla](https://discuss.appium.io/u/karthik_holla)\
**Post date:** [January 23, 2015, 3:55am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/2 "2015-01-23T03:55:35Z")

</div>

Hi @gualber98,

May be this link is helpful.

> [@Connecting appium server to selenium grid for android](https://discuss.appium.io/t/connecting-appium-server-to-selenium-grid-for-android/804/20):
>
> @rgonalo sorry…my mistake…thank you for correcting me… slight_smile will try this and verify…

But if you are trying to execute tests chrome browser the there is an issue with that.

Try this and let me know if this works for you…

Thanks and regards,  
M.Karthik

---

<div class="post-metadata">

**Author:** ![Telmo\_Cardoso](https://discuss.appium.io/user_avatar/discuss.appium.io/telmo_cardoso/32/1435_2.png) [@Telmo\_Cardoso](https://discuss.appium.io/u/Telmo_Cardoso)\
**Post date:** [January 23, 2015, 9:46am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/3 "2015-01-23T09:46:48Z")

</div>

What solved for me was give 10/15 seconds between the start up of each test. I I start both at same time I end up having the ECONNRESET error

---

<div class="post-metadata">

**Author:** ![gualber98](https://discuss.appium.io/user_avatar/discuss.appium.io/gualber98/32/5245_2.png) [@gualber98](https://discuss.appium.io/u/gualber98)\
**Post date:** [January 23, 2015, 6:10pm UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/4 "2015-01-23T18:10:18Z")

</div>

Hi @karthik_holla,  
I went over the link and I have tried the suggestions, but I still can’t get it to work, but I know I now is possible to run in parallel, the issue has to be my settings. I will keep trying.

Also for your issue , do you run appium instance with different --chromedriver-port {number} and --bootstrap-port?

---

<div class="post-metadata">

**Author:** ![gualber98](https://discuss.appium.io/user_avatar/discuss.appium.io/gualber98/32/5245_2.png) [@gualber98](https://discuss.appium.io/u/gualber98)\
**Post date:** [January 23, 2015, 6:11pm UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/5 "2015-01-23T18:11:02Z")

</div>

Hi @Telmo_Cardoso ,

Thank you for the reply, I will try it today.

---

<div class="post-metadata">

**Author:** ![gualber98](https://discuss.appium.io/user_avatar/discuss.appium.io/gualber98/32/5245_2.png) [@gualber98](https://discuss.appium.io/u/gualber98)\
**Post date:** [January 24, 2015, 12:56am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/6 "2015-01-24T00:56:39Z")

</div>

**Update**

After I put a Thread.sleep() after creating the Driver object as @Telmo_Cardoso suggested, I do not longer get the ECONNRESET error but I still cannot get both devices to run,

Now, both Appium server instance run and the App opens on each device, but after gets loaded only one device runs the other just stops. The two threads, each with different Driver object get run on one device. I don’t understand I set the capabilities for each driver to match only one server instances, any suggestions what could be the problem? Thank you

---

<div class="post-metadata">

**Author:** ![karthik\_holla](https://discuss.appium.io/user_avatar/discuss.appium.io/karthik_holla/32/7807_2.png) [@karthik\_holla](https://discuss.appium.io/u/karthik_holla)\
**Post date:** [January 24, 2015, 4:35am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/7 "2015-01-24T04:35:41Z")

</div>

Hi @gualber98,

This is the command that is used to launch the appium server and register it with selenium grid.

C:\Users\mkarthik\Documents\selenium\Appium\node.exe C:\Users\mkarthik\Documents\selenium\Appium\node\_modules\appium\bin\appium.js --address 127.0.0.1 --port 4728 --udid 085d3b920c928938 --bootstrap-port 4724 --nodeconfig C:\Users\mkarthik\workspace\Android\AppiumMobileAutomation\src\com\nodeconfig\085d3b920c928938.json

i am not specifying any chromedriver -port number

regards,  
M.Karthik

---

<div class="post-metadata">

**Author:** ![gualber98](https://discuss.appium.io/user_avatar/discuss.appium.io/gualber98/32/5245_2.png) [@gualber98](https://discuss.appium.io/u/gualber98)\
**Post date:** [January 26, 2015, 9:04pm UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/8 "2015-01-26T21:04:35Z")

</div>

> [@karthik\_holla](#):
>
> But if you are trying to execute tests chrome browser the there is an issue with that.

I was saying that the problem in your case could be because you are not setting up a different --chromedriver-port

---

<div class="post-metadata">

**Author:** ![karthik\_holla](https://discuss.appium.io/user_avatar/discuss.appium.io/karthik_holla/32/7807_2.png) [@karthik\_holla](https://discuss.appium.io/u/karthik_holla)\
**Post date:** [January 27, 2015, 2:52pm UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/9 "2015-01-27T14:52:10Z")

</div>

oh ok, Thanks @gualber98 i will try to execute scripts with different chromedriver port…

thanks for your suggestion.

Regards,  
M.Karthik

---

<div class="post-metadata">

**Author:** ![karthik\_holla](https://discuss.appium.io/user_avatar/discuss.appium.io/karthik_holla/32/7807_2.png) [@karthik\_holla](https://discuss.appium.io/u/karthik_holla)\
**Post date:** [January 28, 2015, 6:14am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/10 "2015-01-28T06:14:07Z")

</div>

@gualber98,

I tried with specifying --chromedriver-port 9516 and 9515 for two different appium instances.

Execution is carried out on a single device. Not sure why commands are not re-directed the second device.

Thanks and regards,  
M.Karthik

---

<div class="post-metadata">

**Author:** ![gualber98](https://discuss.appium.io/user_avatar/discuss.appium.io/gualber98/32/5245_2.png) [@gualber98](https://discuss.appium.io/u/gualber98)\
**Post date:** [February 10, 2015, 6:01pm UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/11 "2015-02-10T18:01:30Z")

</div>

@karthik_holla

“Execution is carried out on a single device.”  
That is exactly what is happening with my execution, any updates on your attempts?

---

<div class="post-metadata">

**Author:** ![maxski](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/8491ac/32.png) [@maxski](https://discuss.appium.io/u/maxski)\
**Post date:** [February 26, 2015, 12:53pm UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/12 "2015-02-26T12:53:01Z")

</div>

Try the example from the thread:

> [@Support for automating multiple devices simultaneously](https://discuss.appium.io/t/support-for-automating-multiple-devices-simultaneously/230):
>
> appium - 1.2.2 Can we automate multiple android devices in a single session of appium? was able to automate multiple devices in different sessions i.e., on different ports by defining two drivers want to know if there is way to do in a single session so that one statement can be executed on both the device at the same time simultaneously than having to wait for a statement execution from a different driver

---

<div class="post-metadata">

**Author:** ![gualber98](https://discuss.appium.io/user_avatar/discuss.appium.io/gualber98/32/5245_2.png) [@gualber98](https://discuss.appium.io/u/gualber98)\
**Post date:** [February 27, 2015, 10:11pm UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/13 "2015-02-27T22:11:49Z")

</div>

Thank you, I will try it out. One question are your running two appium instances?

---

<div class="post-metadata">

**Author:** ![maxski](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/8491ac/32.png) [@maxski](https://discuss.appium.io/u/maxski)\
**Post date:** [March 2, 2015, 9:01am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/14 "2015-03-02T09:01:14Z")

</div>

As mush as you need - android devices connected to PC:-)

---

<div class="post-metadata">

**Author:** ![Fayizkc](https://discuss.appium.io/user_avatar/discuss.appium.io/fayizkc/32/11081_2.png) [@Fayizkc](https://discuss.appium.io/u/Fayizkc)\
**Post date:** [May 12, 2015, 1:47pm UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/15 "2015-05-12T13:47:45Z")

</div>

Can open multiple driver instance with some delay for parallel execution. If all parallel instance are opening simultaneously I am getting ECONNRESET error. So passed one parameter from TestNG xml to wait for 5-10 seconds. It is working file for me 😄

---

<div class="post-metadata">

**Author:** ![siva\_myntra](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/5f8ce5/32.png) [@siva\_myntra](https://discuss.appium.io/u/siva_myntra)\
**Post date:** [June 8, 2015, 8:58pm UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/16 "2015-06-08T20:58:13Z")

</div>

@Fayizkc Can you please provide the testng xml . Need to know how to configure the delay b/w two tests.

---

<div class="post-metadata">

**Author:** ![Fayizkc](https://discuss.appium.io/user_avatar/discuss.appium.io/fayizkc/32/11081_2.png) [@Fayizkc](https://discuss.appium.io/u/Fayizkc)\
**Post date:** [July 24, 2015, 7:24am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/17 "2015-07-24T07:24:09Z")

</div>

Hi Siva.  
Delay is not in the TestNG file. You can implement a logic to stop creating appium capabilities parallel. You can create separate class or method to create WebDriver and make sure you are not hitting that method at the same time.

```
public static boolean driverCreating;  
    WebDriver createApppiumDriver()
    {
    while (driverCreating){}
    driverCreating = true;
     driver = methodForAppiumDriver()
    driverCreating = false;
    }
```

---

<div class="post-metadata">

**Author:** ![saikrishna321](https://discuss.appium.io/user_avatar/discuss.appium.io/saikrishna321/32/5170_2.png) [@saikrishna321](https://discuss.appium.io/u/saikrishna321)\
**Post date:** [March 16, 2016, 11:17am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/18 "2016-03-16T11:17:39Z")

</div>

You can take a look at this

> **[AppiumTestDistribution/AppiumTestDistribution](https://github.com/AppiumTestDistribution/AppiumTestDistribution)**
>
> A tool for running android and iOS appium tests in parallel across devices... U like it STAR it ! - AppiumTestDistribution/AppiumTestDistribution

---

<div class="post-metadata">

**Author:** ![Dhiren\_Mudgil](https://discuss.appium.io/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@Dhiren\_Mudgil](https://discuss.appium.io/u/Dhiren_Mudgil)\
**Post date:** [May 3, 2016, 6:25am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/19 "2016-05-03T06:25:06Z")

</div>

@saikrishna321 I used the above code. But still appium crashes in between.

---

<div class="post-metadata">

**Author:** ![saikrishna321](https://discuss.appium.io/user_avatar/discuss.appium.io/saikrishna321/32/5170_2.png) [@saikrishna321](https://discuss.appium.io/u/saikrishna321)\
**Post date:** [May 4, 2016, 5:58am UTC](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532/20 "2016-05-04T05:58:09Z")

</div>

When u say Appium … Does not give any hint … Can u pls provide the Appium logs when your tests Re triggered in parallel

[Next page](https://discuss.appium.io/t/has-anyone-successfully-run-test-scripts-parallel-in-two-or-more-android-devices/2532.md?page=2)
