How To Set Up Selenium Grid 2 For Cross-Browser Testing

This page shows you how to to set up Selenium Grid 2 running in 2 machines, a WINDOWS and MAC, in parallel.
java -jar selenium-server-standalone-2.23.0.jar -role hub
  • Start a node for Firefox in MAC. 10.12.1.9 is the IP address of the Hub machine. I need to specify the host IP, which is the IP of the MAC because I am in a LAN.
java -jar selenium-server-standalone-2.23.0.jar -role node -hub http://10.12.1.9
:4444/grid/register -browser browserName=firefox,version=3,platform=MAC -hubHost 10.12.1.9 -host “10.12.2.18”
  • Start a node for Internet Explorer in WINDOWS (this is where we start up the Hub)
java -jar selenium-server-standalone-2.23.0.jar -role node -hub http://localhost:4444/grid/register -browser browserName=”internet explorer,version=3,platform=WINDOWS”
  • If you go to http://localhost:4444/grid/console you should see the following:
 
  • You need to have similar 2 programs running in different browsers
Example:
 
program1.cs runs the test in FireFox
 
private DesiredCapabilities capability = DesiredCapabilities.Firefox();
driver = new RemoteWebDriver(new Uri(“http://localhost:4444/wd/hub”), capability);
driver.Navigate().GoToUrl(“https://admin.pageuppeople.com”);
 
program2.cs runs the test in Internet Explorer
 
private DesiredCapabilities capability = DesiredCapabilities.InternetExplorer();
driver = new RemoteWebDriver(new Uri(“http://localhost:4444/wd/hub”), capability);
driver.Navigate().GoToUrl(“https://admin.pageuppeople.com”);
  • You need to use a test framework that is able to run tests in parallel. I am using MbUnit.
In AssemblyInfo.cs, add the following code to run program1.cs and program2.cs in parallel:
 
[assembly: DegreeOfParallelism(2)]
[assembly: Parallelizable(TestScope.All)]

  • Build the DLL for your tests. I am using Ms Visual Studio
  • Load the DLL via Icarus GUI Test Runner to start running the tests
  • You will have both program1.cs running in MAC using FireFox and program2.cs running in WINDOWS using IE8 in parallel