i just made the setup for selenium grid 2. The hub and the nodes are up and running. I'm using Selenium webdriver + C# + Nunit to run my tests, i want now to do the following:
1) Distribute the test cases among different nodes(Parallelism), for example node 1 running test x and node 2 running test y
2) I need to be able to configure the browser and the platform type for each node, what i'm able to do now is that i make one setup function and it uses the same platform and browser for all the nodes, so how can i achieve that by assigning each node's desired capabilities.
The problem is when i run the coming code i find that the tests run simultaneously not parallel.
Snapshot of my code:
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Safari;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Remote;
using NUnit;
using NUnit.Framework;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace GridTest
{
[TestFixture]
[Parallelizable]
public class Test_Grid
{
IWebDriver driver;
[SetUp]
public void Setup()
{
/////IE Setup/////////
var capabilities = new DesiredCapabilities("internet explorer", string.Empty, new Platform(PlatformType.Any));
capabilities.SetCapability("ignoreProtectedModeSettings", true);
driver = new RemoteWebDriver(new Uri("http://localhost:4445/wd/hub"),capabilities);
}
//Search google test
[Test]
[Parallelizable]
public void GoogleSearch()
{
string homepage = "http://www.google.com";
//Navigate to the site
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
driver.Navigate().GoToUrl(homepage);
}
[Test]
[Parallelizable]
public void BingSearch()
{
//var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.bing.com");
}
[TearDown]
public void Teardown()
{
driver.Quit();
}
}
}