In this article I will explain you how you can install and run your Selenium C# scripts on Selenium Grid using MbUnit and Gallio
1. Download Gallio runner
2. Unzip the files to C:\GallioBundle-3.2.603.0
3. Add reference to Mbunit and Gallio in your selenium framework

4. Add MbUnit.Framework namespace to the test script.

5. Add following attributes in AssemblyInfo.cs

6. Add [Parallelizable] attribute to each Test Secripts you want to run in parallel

7. Rebuild the test solution
8. Download Selenium Grid
9. Unzip the files to C:\SeleniumGrid
10. You will have install Java JDK and Ant
11. Go to the selenium grid folder on Command prompt C:\SeleniumGrid and type ant launch-hub
12. Open a new command prompt C:\SeleniumGrid and type ant –Dport=6666 –Denvironment=*iexplore launch-remote-control to launch RC for Internet Explorer
13. Open a new command prompt C:\SeleniumGrid and type ant –Dport=5555 –Denvironment=*firefox launch-remote-control to launch RC for FireFox
14. Now open a new browser window and type http://localhost:4444/console
15. You will see the Selenium Grid Hub 1.0.8-SNAPSHOT

16. Create two selenium test scripts one to run on FireFox and the other on IE
Code for SeleniumGrid1.cs
using System;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading;
using Selenium;
using MbUnit.Framework;
namespace SeleniumTests
{
[TestFixture]
[Parallelizable]
public class SeleniumGrid1
{
private ISelenium selenium;
private StringBuilder verificationErrors;
[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com.au/");
selenium.Start();
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
selenium.Stop();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void SGridTest1()
{
selenium.Open("/");
selenium.Type("q", "seleniumwiki.com");
selenium.Click("btnG");
selenium.WaitForPageToLoad("30000");
try
{
Assert.IsTrue(selenium.IsTextPresent("Selenium Wiki"));
}
catch (Exception e)
{
verificationErrors.Append(e.Message);
}
}
}
}
Code for SeleniumGrid2.cs
using System;
using System.Text;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading;
using Selenium;
using MbUnit.Framework;
namespace SeleniumTests
{
[TestFixture]
[Parallelizable]
public class SeleniumGrid2
{
private ISelenium selenium;
private StringBuilder verificationErrors;
[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com.au/");
selenium.Start();
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
selenium.Stop();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void SGridTest2()
{
selenium.Open("/");
selenium.Type("q", "seleniumwiki.com");
selenium.Click("btnG");
selenium.WaitForPageToLoad("30000");
try
{
Assert.IsTrue(selenium.IsTextPresent("Selenium Wiki"));
}
catch (Exception e)
{
verificationErrors.Append(e.Message);
}
}
}
}
17. Go to C:\GallioBundle-3.2.603.0\bin and double click on Gallio.Icarus.exe
Gallio Icarus window is opened and then you will have to load the dll file with your tests (Selenium Scripts).
Once the dll file is loaded you will see the two test scripts loaded. Select both the tests and click on the start button.

Submitted By Irina Burdilo
If you found this solution helpful or have something extra to add, feel free to share it here by commenting below.

I tried your test and here’s some problem when I tried to modify it:
1/ My firefox profile can not be found, where can I specific my “firefox.exe” for the grid to understand in both server and RC
2/ I tried to start hub and slaves by selenium-server-standalone-2.8.0.jar. Here is my config:
hub
java -jar selenium-server-standalone-2.8.0.jar -role hub
slave 1:
java -jar selenium-server-standalone-2.8.0.jar -role rc -hub http://localhost:4444/grid/register -browser browserName=iexplore,platform=WINDOWS -port 5556
slave 2:
java -jar selenium-server-standalone-2.8.0.jar -role rc -hub http://localhost:4444/grid/register -browser browserName=safari,platform=WINDOWS -port 5557
I went to http://localhost:4444/grid/console to check and everything is fine
However, when I run the test, it throw me an error: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
Please tell me why I encounter this error? Thank you !
My firefox profile can not be found, where can I specific my “firefox.exe” for the grid to understand in both server and RC
If you are using a 64 bit processor please follow the following post
http://www.seleniumwiki.com/selenium-rc/selenium-seleniumexception-firefox-path-not-found-windows-7/
I will look into the other issue and let you know soon
This is good tutorials but we have need to run single script run in different-2 browser as in TestNG
How it possible?
Thanks,
Sadik Ali