title: How to run tests in parallel using C# Specflow, MsTest Appium with selenium grid
body: <p>I am unable to run tests parallel in two iOS devices (have different udids) I can see both tests are trying to run on one device only instead of running in parallel mode. One test always fails and other passes for some reason but both passes if I run independently.</p>
  <p>I ran out my google search options and posting my question, can someone please help what I am missing in setup.
  I have created two iOS simulators and created two node json files and selenium hub and two nodes are running on same machine. Selenium hub is running and registered both nodes successfully.</p>
  <p>I have two feature files in my solution and using Test Explorer to run the tests.</p>
  <p>Selenium Grid commands used:</p>
  <ul>
  <li>Hub</li>
  </ul>
  <blockquote>
  <p>java -jar selenium-server-standalone-3.141.59.jar -role hub</p>
  </blockquote>
  <ul>
  <li>Node 1</li>
  </ul>
  <blockquote>
  <p>appium -p 4726 --nodeconfig iOS14_N2D2_4726.json</p>
  </blockquote>
  <ul>
  <li>Node 2</li>
  </ul>
  <blockquote>
  <p>appium -p 4724 --nodeconfig iOS14_N1D1_4724.json</p>
  </blockquote>
  <p>Packages used:</p>
  <pre><code>  &lt;ItemGroup&gt;
      &lt;PackageReference Include=&quot;Appium.WebDriver&quot; Version=&quot;4.3.1&quot; /&gt;
      &lt;PackageReference Include=&quot;DotNetSeleniumExtras.WaitHelpers&quot; Version=&quot;3.11.0&quot; /&gt;
      &lt;PackageReference Include=&quot;Microsoft.NET.Test.Sdk&quot; Version=&quot;16.10.0&quot; /&gt;
      &lt;PackageReference Include=&quot;SpecFlow.Plus.LivingDocPlugin&quot; Version=&quot;3.8.35&quot; /&gt;
  
      &lt;PackageReference Include=&quot;SpecFlow.MsTest&quot; Version=&quot;3.8.14&quot; /&gt;
      &lt;PackageReference Include=&quot;MSTest.TestAdapter&quot; Version=&quot;2.2.4&quot; /&gt;
      &lt;PackageReference Include=&quot;MSTest.TestFramework&quot; Version=&quot;2.2.4&quot; /&gt;
      
      &lt;PackageReference Include=&quot;FluentAssertions&quot; Version=&quot;5.10.3&quot; /&gt;
      
    &lt;/ItemGroup&gt;
  </code></pre>
  <p>Added this line to one of the Binding class</p>
  <pre><code>[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)]
  </code></pre>
  <p>Folder Structure</p>
  <p><a href="https://i.stack.imgur.com/EIfYt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EIfYt.png" alt="my folder structure" /></a></p>
  <p>calling the driver as below and registering as instance</p>
  <pre><code>using BoDi;
  using Microsoft.VisualStudio.TestTools.UnitTesting;
  using OpenQA.Selenium;
  using OpenQA.Selenium.Appium;
  using OpenQA.Selenium.Appium.Enums;
  using OpenQA.Selenium.Appium.iOS;
  using System;
  using TechTalk.SpecFlow;
  [assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)]
  
  namespace SpecflowParallel.Driver
  {
      [Binding]
      public class DriverSetup
      {
          private IObjectContainer _objectContainer;
          public AppiumDriver&lt;IWebElement&gt; Driver;
          public DriverSetup(IObjectContainer objectContainer)
          {
              _objectContainer = objectContainer;
          }
  
          [BeforeScenario]
          public void BeforeScenario()
          {
               Driver = GetDriver();
              _objectContainer.RegisterInstanceAs(Driver);
          }
  
        public AppiumDriver&lt;IWebElement&gt; GetDriver()
          {
              var caps = new AppiumOptions();
              caps.AddAdditionalCapability(MobileCapabilityType.PlatformName, &quot;IOS&quot;);
              caps.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, &quot;14.4&quot;);
              caps.AddAdditionalCapability(MobileCapabilityType.DeviceName, &quot;iPhone 8 Plus&quot;);
              caps.AddAdditionalCapability(MobileCapabilityType.AutomationName, &quot;XCUITest&quot;);
              caps.AddAdditionalCapability(MobileCapabilityType.App, &quot;/Users/automation/build/myapp.ios.app.zip&quot;);    
              Driver = new IOSDriver&lt;IWebElement&gt;(new Uri(&quot;http://10.1.1.92:4444/wd/hub&quot;), caps);
              return Driver;
          }
      }
  }
  </code></pre>
  <p>Node1 - iOS14_N2D2_4726.json</p>
  <pre><code>  {
      &quot;capabilities&quot;:
      [
          {
              &quot;browserName&quot;: &quot;Safari&quot;,
              &quot;platformName&quot;: &quot;IOS&quot;,
              &quot;platformVersion&quot;: &quot;14.4&quot;,
              &quot;maxInstances&quot;: 2,
              &quot;automationName&quot;: &quot;XCUITest&quot;,
              &quot;appPackage&quot;: &quot;myapp.droid.integration&quot;,
              &quot;AppActivity&quot;: &quot;myapp.LaunchActivity&quot;,
              &quot;wdaLocalPort&quot;:&quot;8142&quot;,
              &quot;udid&quot;:&quot;188BA7D5-905F-473E-9CF9-3A49555F587C&quot;
          }
      ],
      &quot;configuration&quot;:
      {
          &quot;cleanUpCycle&quot;:2000,
          &quot;timeout&quot;:30000,
          &quot;proxy&quot;: &quot;org.openqa.grid.selenium.proxy.DefaultRemoteProxy&quot;,
          &quot;host&quot;: &quot;10.1.1.92&quot;,
          &quot;port&quot;: 4726,
          &quot;maxSession&quot;: 1,
          &quot;register&quot;: true,
          &quot;registerCycle&quot;: 5000,
          &quot;hubPort&quot;: 4444,
          &quot;hubHost&quot;: &quot;10.1.1.92&quot;,
          &quot;hubProtocol&quot;: &quot;http&quot;,
          &quot;url&quot;:&quot;http://10.1.1.92:4726/wd/hub&quot;
      }
  }
  </code></pre>
  <p>Node2 - iOS14_N1D1_4724.json</p>
  <pre><code>  {
      &quot;capabilities&quot;:
      [
          {
              &quot;browserName&quot;: &quot;Safari&quot;,
              &quot;platformName&quot;: &quot;IOS&quot;,
              &quot;platformVersion&quot;: &quot;14.4&quot;,
              &quot;maxInstances&quot;: 2,
              &quot;automationName&quot;: &quot;XCUITest&quot;,
              &quot;appPackage&quot;: &quot;myapp.droid.integration&quot;,
              &quot;appActivity&quot;: &quot;myapp.LaunchActivity&quot;,
              &quot;wdaLocalPort&quot;:&quot;8141&quot;,
              &quot;udid&quot;:&quot;0227DEF2-DF40-47A1-AE95-EFFBC69FAB37&quot;
          }
      ],
      &quot;configuration&quot;:
      {
          &quot;cleanUpCycle&quot;:2000,
          &quot;timeout&quot;:30000,
          &quot;proxy&quot;: &quot;org.openqa.grid.selenium.proxy.DefaultRemoteProxy&quot;,
          &quot;host&quot;: &quot;10.1.1.92&quot;,
          &quot;port&quot;: 4724,
          &quot;maxSession&quot;: 1,
          &quot;register&quot;: true,
          &quot;registerCycle&quot;: 5000,
          &quot;hubPort&quot;: 4444,
          &quot;hubHost&quot;: &quot;10.1.1.92&quot;,
          &quot;hubProtocol&quot;: &quot;http&quot;,
          &quot;url&quot;:&quot;http://10.1.1.92:4724/wd/hub&quot;
      }
  }
  </code></pre>
  <p>Happy to provide further info</p>