1

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 Answers 2

1

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 ?

Sign up to request clarification or add additional context in comments.

2 Comments

Krishnan, I doubt that. I think hub doesn't exhaust all the browsers of one node and then goes for second node. I think it assigns first request to first browser of the node1 then second request to first browser of node2 and third request to first browser of node3 and then it repeats the cycle. Correct me if I am wrong.
@pArAs Apparently the logic for node distribution seems to have changed recently. As part of the commit github.com/SeleniumHQ/selenium/commit/… the behavior has changed to consider resource utilisation and then couple that information with the timestamp of the last session that was created (if there are two nodes with the same resource utilisation) to decide this. So I would not say roughly its like a round robin technique which goes node after node for new session distribution, but on a high level yeah it can be called so as well.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.