Selenium:Running parallel tests on different browser

29 February 2016 by Pushkar Deshpande No comments

Run parallel test execution in 3 easy steps:

• Setting up Selenium Grid Server
• Adding node to hub
• Sample Code using TestNG

Setting up Selenium Grid Server

  1. – Download Selenium server (.jar) from : Selenium Standalone Jar
  2. – Place the .jar file at preferred location
  3. – Open command prompt and go to the location where .jar file is placed
  4. – Run command : java -jar selenium-server-standalone-2.52.0.jar -role hub
  5. – Verify whether hub is running using URL :  http://localhost:4444/grid/console

Adding node to hub

  1. –  Open a new command prompt instance (as hub is already running on previous instance) and go to the location where .jar is placed
    Run following command :
    java -jar selenium-server-standalone-2.52.0.jar -role webdriver -hubhttp://172.16.15.140:4444/grid/register -port 5568
    (Note that the IP address provided should be of the client machine. If you are running scripts on same machine then use same IP address of the server machine.)
  1. – Above command will add a single node to the hub.
  1. –  To add multiple nodes open and run same command in new command prompt. Make sure that the port will be different for each node.
    eg.
    1. java -jar selenium-server-standalone-2.52.0.jar -role webdriver -hubhttp://172.16.15.140:4444/grid/register -port 5568
    2.  java -jar selenium-server-standalone-2.52.0.jar -role webdriver -hubhttp://172.16.15.140:4444/grid/register -port 5569
    Above node will work successfully for Firefox
  1. – If you are trying to add a node to hub for Internet Explorer (IE) use
    following command :
    java -jar selenium-server-standalone-2.52.0.jar -role webdriver -hubhttp://172.16.15.140:4444/grid/register -port 5555 -Dwebdriver.ie.driver=”C:/Selenium/Grid/Resource/IEDriverServer.exe”
  1. – Verify whether hub and nodes are running using following URL :
    http://localhost:4444/grid/console

 

Sample Java and XML code

JavaCode   XMLFile

Pushkar Deshpande

Follow me on Twitter

Subscribe To Our Blog

Get access to proven marketing ideas, latest trends and best practices.

Next up home

Contact

Lets build cool stuff

Share your contact information & we will get in touch!

I want (Tell us more about your dream project)