2

Here I have created a hub and a Node and I want to create another node.

How can I initialize my RemoteWebdriver with multiple nodes.

public void setUp() throws MalformedURLException{
    baseUrl="http://10.77.16.133/cpos-alttech/";
    nodeUrl="http://172.29.69.175:8080/wd/hub";
    DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
    capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    capability.setBrowserName("internet explorer");
    capability.setPlatform(Platform.WINDOWS);
    driver = new RemoteWebDriver(new URL(nodeUrl), capability);

}
ro.e
  • 319
  • 1
  • 3
  • 13
Mani shankar
  • 35
  • 1
  • 5

1 Answers1

0

I recommend registering the nodes to the hub as mentioned below:

I usually like to start a hub (with the 'start the hub' command below) first and then I register the nodes to the hub (using the 'start the node' command below).

In the code, I pass the desired capabilities that suits the hub configurations.

Refer to Starting Selenium-Grid:

To start a hub:

To start a hub with default parameters, run the following command from a > command-line shell. This will work on all the supported platforms, > >Windows Linux, or Mac OSX.

java -jar selenium-server-standalone-2.44.0.jar -role hub

To start a node:

To start a node using default parameters, run the following command from > a command-line.

java -jar selenium-server-standalone-2.44.0.jar -role node -hub http://localhost:4444/grid/register

So in order the add more nodes, just run the "start node command" from the desired machines or processes

ro.e
  • 319
  • 1
  • 3
  • 13
  • e Thanks ro for your reply. I have registered two nodes ,and in my code (which i provided above) i am initializing the RemoteWebdriver with one node IP(String nodeUrl ) address then what about another node.Where do i mention that node. – Mani shankar Jan 19 '15 at 12:58
  • You need to pass the `hub url` and the `capability` to the `RemoteWebDriver`. The hub will take care for the nodes for you. You can also check the hub status in your browser. For example I set a hub on 10.10.10.20:4444/ and connected two nodes to it. If I enter `http://10.20.102.176:4444/grid/console` I could see the hub status with the two connected nodes – ro.e Jan 19 '15 at 13:32
  • Thanks ro, it worked but my script is executing on only one node, the node which is registered first. Script is not executing on the node which is registered second.Can you help on this – Mani shankar Jan 19 '15 at 13:42
  • You need to run multi-processes. For example (without multiprocessing) try to create 2 RemoteWebDriver instances and navigate to some url. You should be able to see that the 2 nodes are working. – ro.e Jan 19 '15 at 13:50