How to run python webdriver test scripts using Grid2

  1. Java and python should be installed and setup path in your machine..
  2. Download from below url:
  3. Download and install “setuptools 0.6c11” from below link:
  4. Install selenium 2 in your system using command: > easy_install selenium
  5. Selenium server file should be in machine
Set up and launching Selenium Grid:

      1. Run below command in on your console to launch Grid hub console:
java -jar selenium-server-standalone-2.21.0.jar -host localhost -port 4444 -role hub
       2. Open two console and run below command to launch and register node with Grid hub.
java -jar selenium-server-standalone-2.21.0.jar -host localhost -port 5555 -role webdriver -hub http://localhost:4444/grid/register -browser browserName=firefox,platform=WINDOWS

java -jar selenium-server-standalone-2.21.0.jar -host localhost -port 5556 -role webdriver -hub -browser browserName=iexplore,platform=WINDOWS
           Replace local host to system IP of Hob machine. If you want to launch node in different machine.

Test script::

Put “” downloaded file in your project and create a scripts as like below script.

from selenium import webdriver
import unittest
import sys
from  xmlrunner import *

class Grid2(unittest.TestCase):
    capabilities = None
    def setUp(self):       
        self.driver = webdriver.Remote(desired_capabilities={           
            "browserName": browser,
        print "set up executed"
    def test_example(self):
        print "open google url"
        self.assertEqual(self.driver.title, "Google")
        print "verify title"
        print "enter text in serach field"
        print "click on search button"   

    def tearDown(self):

if __name__ == "__main__":
    args = sys.argv   
    port  = args[1]
    platform  = args[2]
    browser = args[3]
    suite = unittest.TestSuite()
    runner = XMLTestRunner(file('results_ExampleTestCase_%s.xml' % (browser), "w"))


Open two consoles go to your test scripts project and run below command one by one.

python 5555 WINDOWS firefox
python 5556 WINDOWS iexplore

Where is created test script.
After execution two xml files are generated under project for each execution.


  1. Awesome post for Grid implementation with python....

  2. This was really helpful for learning the Python syntax. Thanks!!!

  3. I am looking for Nose Framework one is there any one help me
    Thanks in advance

  4. Couldn't register this node: The hub is down or not responding: Connect to localhost:4444 [localhost/, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect

    I am getting this issue .....Help me please


Leave your comments, queries, suggestion I will try to provide solution