Selenium
Grid distributes our tests across multiple machines so that we can run them in
parallel, cutting down the time required for running tests.
The
selenium-server-standalone package includes the Hub, WebDriver, and Selenium RC .
Setting
up Hub: (Simple)
java
-jar selenium-server-standalone-2.53.0.jar -port 4444 -role hub
Setting
up Node:(Simple)
java
-jar selenium-server-standalone-2.53.0.jar -role webdriver -hub http://xx.xx.xx.xx:4444/grid/register
–port 8989
Setting
up Node:(Complex)
If you want to setup a
node with only IE browsers
Option1: via Command Text
java
-jar selenium-server-standalone-2.53.0.jar -role webdriver -browser
"browserName=internet explorer,version=11,maxinstance=1,platform=WINDOWS" -hub http://xx.xx.xx.xx:4444/grid/register
–port 8989
Option2: via Json file
Save below Json as selenium-node-win-ie11-cfg.json
{
"class": "org.openqa.grid.common.RegistrationRequest",
"capabilities":
[
{ "seleniumProtocol": "WebDriver",
"browserName": "internet explorer",
"version": "11",
"maxInstances": 1,
"platform" :
"WINDOWS"
}
],
"configuration":
{
"port": 8989,
"register": true,
"host": "xx.xx.xx.100",
"proxy": "org.openqa.grid.selenium.proxy. DefaultRemoteProxy",
"maxSession": 2,
"hubHost": "xx.xx.xx.100",
"role": "webdriver",
"registerCycle": 5000,
"hub": "http://xx.xx.xx.100:4444/grid/register",
"hubPort": 4444,
"remoteHost": "http://xx.xx.xx.101:8989"
}
}
one
more json:
{
"capabilities":
[
{
"browserName": "chrome",
"maxInstances": 5
},
{
"browserName": "firefox",
"maxInstances": 5
},
{
"browserName": "internet explorer",
"maxInstances": 5
},
{
"browserName": "safari",
"maxInstances": 5
}
],
"configuration":
{
"_comment": "Configuration for Node",
"nodeTimeout":120,
"port":5555,
"hubPort":4444,
"hubHost":"hubIpAddress",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":5,
}
}
Command Text:
java -jar selenium-server-standalone-53.jar -role webdriver -nodeConfig selenium-node-win-ie11-cfg.json
Selenium
Remote WebDriver code:
DesiredCapabilities cap = new DesiredCapabilities();
cap.setBrowserName("firefox");
cap.setPlatform(org.openqa.selenium.Platform.WINDOWS);
WebDriver driver = new RemoteWebDriver(new URL("http://xx.xx.xx.xx:4444/wd/hub"),cap);
Suite.xml:
<suite name="Parallel Tests" verbose="1" thread-count="4"
parallel="tests">
</suite>
thread-count=“4” describes the maximum number of threads to be executed in parallel.
---------------------------------------------------------------------------------------------------------------------------------
Each node contains 5 Chrome, 5 Firefox and 1 IE browser under Browser section like below.
Do you want only one IE browser?
java -jar selenium-server-standalone-2.41.0.jar -role webdriver -hub
http://localhost:4444/grid/register
-port 5556 -browser browserName=iexplore
You want one browser per each type?
java -jar
selenium-server-standalone-2.41.0.jar -role webdriver -hub
http://localhost:4444/grid/register
-port 5556 -browser browserName=iexplore
-browser browserName=firefox -browser browserName=chrome
maxInstances:
maxInstance is used to limit the number
of browser initialization in a node.
For example if you want to work with 2 Firefox and
2 IE then you can start the node using maxInstance.
java -jar
selenium-server-standalone-2.41.0.jar -role webdriver -hub
http://localhost:4444/grid/register
-port 5556 -browser browserName=firefox,maxInstance=3
maxSession:
maxSession is used to configure how many
number of browsers can be used parallel in the remote system.
java -jar
selenium-server-standalone-2.41.0.jar -role webdriver -hub http://localhost:4444/grid/register
-port 5556 -browser browserName=chrome,maxInstance=3 -browser browserName=firefox,maxInstance=3
–maxSession 3
Nice post, first of all Thanks for writing such lovely Post! Earlier I thought that posts are the only most important thing on any blog..
ReplyDeleteSelenium Training in Chennai
Dot Net Training in Chennai
Hadoop Training in Chennai
Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!
ReplyDeleteselenium training in chennai|
Good article about selenium grid.Thank for shared.keep update software testing training with job guarantee
ReplyDeleteselenium training in velachery
selenium training in chennai
selenium online trainings
ReplyDeleteselenium online trainings from India