Installing Selenium Grid with MbUnit and Gallio

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.