1
votes

Following is my code -

DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setBrowserName("firefox");
capability.setPlatform(Platform.VISTA);
driver  = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
driver.manage().window().maximize();
driver.get(url);

I want to execute my script on 3 different nodes

For starting HUB I am using the command :- java -jar selenium-server-standalone-2.53.0.jar -role hub -port 4444

and for nodes

Node 1 :- java -jar selenium-server-standalone-2.53.0.jar -role webdriver -hub http://192.168.1.118:4444/grid/register -port 5556

Node 2 :- java -jar selenium-server-standalone-2.53.0.jar -role webdriver -hub http://192.168.1.118:4444/grid/register -port 5557

Node 3 :- java -jar selenium-server-standalone-2.53.0.jar -role webdriver -hub http://192.168.1.118:4444/grid/register -port 5558

All 3 nodes are on 3 different machines So my question is do i need to mention all 3 nodes ip address in my code or is there any way to execute script parallely on all 3 machines ?

2

2 Answers

1
votes

No you cannot do this directly. By default I think a node supports 5 sessions. So only after all the 5 sessions in node 1 have been exhausted, can the tests go to the second node. So for you to be able to run your tests in parallel on all the 3 nodes, you would need to start all your nodes with a maxSession of 1 and then spin off 3 threads for your tests. That would cause all the nodes to run your tests simultaneously. But just wondering why would you want to run your tests against all the nodes ? What is your use case ?

1
votes

If you are using testNG then you can use the 'parallel' attribute in testng.xml for a sample blog refer here.

you can also use Maven's maven-failsafe-plugin with <forkCount> tag, have a look at this.

hope this helps.