Set up and launching Selenium Grid:

1. Launching Hub: Open command prompt got to your selenium server jar file and run command: > “java -jar selenium-server-standalone-2.21.0.jar -host localhost -port 4444 -role hub”
2. Launching Node 1: open command prompt go to you selenium server jar file and execute command: > “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”
3. Launching Node 2: open another command prompt go to you selenium server jar file and execute command: > “java -jar selenium-server-standalone-2.21.0.jar -host localhost -port 5556 -role webdriver -hub http://192.168.1.22:4444/grid/register -browser browserName=iehtafirefox,platform=WINDOWS”

Script Creation: below is sample of Python selenium Grid script:
from selenium import webdriver
import unittest
import sys
from xmlrunner import *

class ExampleTestCase(unittest.TestCase):

capabilities = None
def setUp(self):
self.driver = webdriver.Remote(desired_capabilities={
“browserName”: broswer,
“platform”: platform
“node”:node })

def test_example(self):
self.driver.get(“www.360logica.com“)
self.assertEqual(self.driver.title, “360logica”)
def tearDown(self):
self.driver.quit()

if __name__ == “__main__”:
args = sys.argv
port = args[1]
platform = args[2]
broswer = args[3]
suite = unittest.TestSuite()
suite.addTest(ExampleTestCase(‘test_example’))
runner = XMLTestRunner(file(‘results_ExampleTestCase_%s.xml’ % (broswer), “w”))
runner.run(suite)

Note: you need to put “xmlrunner.py” in your script folder.
Script Execution:
Open two command prompts and go to your script directory and run below command one by one on open command prompt:
> python {YourScriptName}.py 5555 WINDOWS iehta
> python {YourScriptName}.py 5556 WINDOWS firefox

Please feel free to post queries or share your views related to above.

Thanks,
Rohit Singh
www.360logica.com