Selenium
Grid :
- Grid is a selenium advanced tool that distributes the tests across multiple physical/Remote machines so that we can execute scripts in parallel.
- Grid uses the same code which is placed in HUB machine, hence the code need NOT be present on the system they execute
Basics
of Selenium Grid:
Hub:
- Hub is central point to the entire GRID Architecture which receives all requests.
- There is only one hub in the selenium grid. Hub distributes the test cases across each node.
- In simple words, Hub means the machine where you put your source code.
Node:
- There can be multiple nodes in Grid.
- Tests will run in nodes. Each node communicates with the Hub and performs test assigned to it.
- In simple words, nodes means your remote virtual machines where your test cases execution takes place.
Steps
to Configure Selenium Grid:
Step
1: Download
Selenium Server jar file from Selenium’s official website here
http://docs.seleniumhq.org/download/
Step
2:
After
download the jar, navigate to the folder location where you placed
your downloaded Selenium-server-standalone jar.
For
example, After downloaded the jar by default jar will present in
downloads folder
Lets
assume jar present in “c:/MachineA/downloads”
location.
Step
3:
Open
command prompt, navigate upto downloaded server location path like
below:
How
to Run HUB commands in command prompt:(Machine
A)
- In Machine A I want to run the HUB
- Open cmd prompt and Enter “cd c:/MachineA/downloads”
- Now copy your downloaded jar name (Ex: selenium-server-standalone-2.41.0)
- Now Enter command “java -jar <<paste your downloaded jar name>>.jar -role hub”
- Example : java -jar selenium-server-standalone-2.41.0.jar -role hub
- Click Enter Button
How
to Run Node commands in command prompt:(Machine
B)
- Login to Machine B,I want to run the Node
- Now copy your downloaded jar name (Ex: selenium-server-standalone-2.41.0)
- Now Enter command “java -jar <<paste your downloaded jar name>>.jar -role node -hub http://<<Machine A Ip Address>>:4444/grid/register”
- Example : java -jar selenium-server-standalone-2.41.0.jar -role node -hub http://120.23.104.00:4444/grid/register
In
Machine A (where HUB running):
Once
you are done your above HUB and Node steps, we can see the HUB
running status by opening your firefox or Chrome browser and access this
running status by opening your firefox or Chrome browser and access this
- Example : http:// 120.23.104.00:4444/grid/console
This
indicates that By default you can use (selenium grid)
- 5 Chrome
- 5 Firefox
- 1 IE browser
Note: if you are running HUB and Node commands in same machine, you can give localhost in below Node command like below
- HUB command is same as mentioned above
- Node command:
- java -jar <<paste your downloaded jar name>>.jar -role node -hub http://localhost:4444/grid/register
We can see the HUB running status by opening your firefox or Chrome browser and access this
http:// localhost:4444/grid/console