0

I want to run the test in 2 different machines(2 different nodes) on the same network using SELENIUM GRID2.

When i run the test, test is running in one node(node registered first to the hub)

Launched a GRID Hub in - http://11.111.111.11:4444

Registered 2 nodes from 2 different machines in the same network.

Node 1 :

xxxx://11.111.111.11:4444/grid/register -port 5557

Node 2 :

xxxx://11.111.111.11:4444/grid/register -port 5558

finally passed/provided the hub URL in the code mentioned below

String hubURL = "xxxx://11.111.111.11:4444/wd/hub";

driver = new RemoteWebDriver(new URL(hubURL), caps);

But the test is running in one node(node registered first to the hub)

The test is not getting executed/running in 2 nodes

Please help me with this scenario

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
Ansari
  • 3
  • 3

1 Answers1

0

Allocating a test to a node is an attribute of the grid. What would be getting by wanting to run a test only a particular node ?

That being said, you can basically route a test to a particular node, using the following options

  1. When you start the node, you basically set its maxSession to 1. That way a node will serve only one test at a time. This is a configuration that you would need to pass at the node level via a nodeConfig argument, pointing the selenium node to a JSON configuration file. For more details refer to my blog here
  2. The second approach is a bit complex and would require you to build some customization. You would need to make use of a custom capability matcher which you would need to inject into the grid and then via your desired capabilities object you can pass in the custom capability and the grid would route your test to that one particular node all the time. Its kind of a way to create node affinity to your tests and is particularly useful when you are trying to debug a failure that happens only on a particular node. You can read more about working with custom capabilities in my blog post here.
Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66