Running Test in Remote machine with new WebDriver functionality (Grid 2)

Earlier days we can run Selenium test in multiple machine ONLY using Selenium 1 RC (The Project name called Selenium Grid). The biggest downside with Selenium Grid is that, it doesn’t support Webdriver.

But now with Grid 2, both Selenium 1 and Webdriver are supported and we can run test in multiple machines. Grid 2 will allow you to do following

· Scale by distributing tests on several machines ( parallel execution )

· Manage multiple environments from a central point, making it easy to run the tests against a vast combination of browsers / OS.

· Minimize the maintenance time for the grid by allowing you to implement custom hooks to leverage virtual infrastructure for instance.

Steps to run test in multiple machine using Grid 2

Step1 (HUB)

Start the Selenium standalone server with following command

Now the Command prompt window will look like this

image

If you could see the above screen shot, selenium server once started, it started as a Selenium grid Server.

The hub will automatically start-up using port 4444 by default. To change the default port, you can add the optional parameter -port when you run the command. You can view the status of the hub by opening a browser window and navigating to: http://localhost:4444/grid/console

Step2 (Node)

Now start the node from the same Selenium standalone server package itself in command prompt, since Selenium standalone server package itself includes Hub, Webdrivers and RC

Now the Console looks like this

image

 

Now once you go back to your browser and check the link http://localhost:4444/grid/console it will look like this

image

 

By default Grid 2 starts 11 browsers : 5 Firefox, 5 Chrome, 1 Internet Explorer. The maximum number of concurrent tests is set to 5 by default.

Running Test using RC and Webdriver

For the Selenium 1 RC nodes, you can continue to use the DefaultSelenium object and pass in the hub information

Similarly for running test using Webdriver, use RemoteWebDriver instead of WebDriver and DesiredCapabilities object to define browser, OS version etc.

Pass the code to RemoteWebdriver object also

The Complete working code will look like this.

That’s it.

Enjoy running Test in Distributed Environment !!

Thanks,

Karthik KK

One thought on “Running Test in Remote machine with new WebDriver functionality (Grid 2)

  1. hi , thanks for the detailed explanation. First two images are not visible. I checked in chrome and FF. Pls check that. If its visible, it will help us better

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">