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
gallio 226x300 Installing Selenium Grid with MbUnit and Gallio
4. Add MbUnit.Framework namespace to the test script.
MbUnit.Framework Installing Selenium Grid with MbUnit and Gallio

5. Add following attributes in AssemblyInfo.cs
AssemblyInfo Installing Selenium Grid with MbUnit and Gallio
6. Add [Parallelizable] attribute to each Test Secripts you want to run in parallel
Parallelizable Installing Selenium Grid with MbUnit and Gallio
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
Snapshot Installing Selenium Grid with MbUnit and Gallio
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.
GallioIcarus Installing Selenium Grid with MbUnit and Gallio

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.


Google Webdriver Forum -The Online Community for Google Webdriver and Selenium RC Users and Professionals
3 responses to “Installing Selenium Grid with MbUnit and Gallio”
  1. ndhai says:

    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 !

  2. sadik ali says:

    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

Leave a Reply