NOTE: this post is based on the selenium-server-standalone-2.16.1 release.
So we finally have Grid 2, Grid 2 is a complete re-write of Selenium Grid and brings us the following features:- Support for Selenium-Webdriver (Selenium 2)
- Full backwards compatibility with Selenium-RC (Selenium 1)
- Significant optimisations both in terms of efficiency and functionality, the headline being you no longer need a 1:1 mapping betweeen RC instances and browsers which meant huge memory consumption. Now a single node server can support all browsers for that node.
I have only just started looking at Grid 2 so this is going to be a very brief overview. Hopefuly as I explore its functionality further i’ll do some more involved posts.
Pretty much everything you need to get started is on the Wiki page but below are a few things that might be useful to clarify in order to get the ‘out of the box’ behaviour working.
start a hub server :
java -jar selenium-server-standalone-2.16.1.jar -firefoxProfileTemplate /home/slaouini/tools/selenium-server/web
start a node server :
java -jar selenium-server-standalone-2.16.1.jar -role node -hub http://127.0.0.1:4444/grid/register -nodeConfig myconfig.json -firefoxProfileTemplate /home/slaouini/tools/selenium-server/web
By default the grid will start with a default set of browsers, 5 Firefox, 5 Chrome, 1 IE - you can change this configuration by supplying command line options when you start the node server, see the Selenium Wiki for more details.
Alternatively you can supply a config file in json format e.g.
our json config file :
{
"class":"org.openqa.grid.common.RegistrationRequest",
"capabilities":
[
{
"seleniumProtocol":"Selenium",
"browserName":"*firefox",
"maxInstances":20},
{
"seleniumProtocol":"Selenium",
"browserName":"*googlechrome",
"maxInstances":20
},
{
"seleniumProtocol":"Selenium",
"browserName":"*iexplore",
"maxInstances":10
},
{
"seleniumProtocol":"WebDriver",
"browserName":"firefox",
"maxInstances":20
},
{
"seleniumProtocol":"WebDriver",
"browserName":"chrome",
"maxInstances":20
},
{
"seleniumProtocol":"WebDriver",
"browserName":"internet explorer",
"maxInstances":10
}
],
"configuration":
{
"port":5555,
"host":"10.222.9.127",
"hubHost":"127.0.0.1",
"registerCycle":5000,
"hub":"http://127.0.0.1:4444/grid/register",
"url":"http://10.222.9.127:5555",
"remoteHost":"http://10.222.9.127:5555",
"register":true,
"proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"firefoxProfileTemplate":"/home/slaouini/tools/selenium-server/web",
"maxSession":20,
"role":"node",
"hubPort":4444
}
}
Parallelism on the Client
If you are using testng to drive your tests this is most easily done using either the testng xml test suite file.
Essentially it allow you to run either parallel across cores and/or threads. Obviously the choice will be determined by your execution environment e.g. if running in a CI queue your job may only have a single core therefore you are better to go for multiple threading also when all we are doing is feeding some code to a remote server that is going to run the tests then having multiple threads may seem more sensible.
our testng file :
<suite name="SeleniumTests" parallel="tests" thread-count="10" verbose="10">
<test name="TEST01" >
<parameter name="webSite" value="http://10.222.4.109:8080/admin-console/"/>
<parameter name="seleniumHost" value="127.0.0.1"/>
<parameter name="seleniumPort" value="4444"/>
<parameter name="browser" value="*firefox"/>
<parameter name="timeout" value="10000"/>
<classes>
<class name="com.test.selenium.TEST01" />
</classes>
</test>
....
<test name="TESTN" >
<parameter name="webSite" value="http://10.222.4.109:8080/admin-console/"/>
<parameter name="seleniumHost" value="127.0.0.1"/>
<parameter name="seleniumPort" value="4444"/>
<parameter name="browser" value="*chrome"/>
<parameter name="timeout" value="10000"/>
<classes>
<class name="com.test.selenium.TESTN" />
</classes>
</test>
</suite>
Conclusions
So there you have it…I have barely scratched the surface of what I believe Grid 2 can offer, from listening to the presentation by the authors there is mouch more to discover.
That's all folks, take care :)





