sridhar249
sridhar249

Reputation: 5061

selenium grid listening on node port instead of hub port

For my test, I am running grid and node locally on different ports.

java -jar /usr/bin/selenium-server.jar -port 4444 -role hub
java -jar /usr/bin/selenium-server.jar -role node -hub http://127.0.0.1:4444/grid/register -port 5556

So, the grid is running on 4444 and node is running on 5556.

In my test, if i start the driver as

driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=desired_capabilities)

then the test fails with the exception

response = {'status': 500, 'value': '{"status":13,"value":{"class":"java.lang.NullPointerException","stackTrace":[{"fileName":"Ha...n","lineNumber":590},{"fileName":"Thread.java","className":"java.lang.Thread","methodName":"run","lineNumber":745}]}}'}

The test passed if i run the test on the node port 5555, instead of the hub port 4444, as shown below

driver = webdriver.Remote(command_executor='http://127.0.0.1:5555/wd/hub', desired_capabilities=desired_capabilities)

I was of the opinion that, we should be running the tests on the hub port, which in this case is 4444 and not 5555.

Please correct me if i am wrong.

Upvotes: 1

Views: 5067

Answers (3)

undetected Selenium
undetected Selenium

Reputation: 193128

If you intend to use Selenium in Grid configuration through Hub and Node configuration, I would suggest you to use the most recent selenium-server-standalone-3.6.0 jar as follows:

  1. Start the Selenium Grid Hub (by default on port 4444) :

    java -jar selenium-server-standalone-3.6.0.jar -role hub
    
  2. Confirm the Selenium Grid Hub is started:

    16:06:29.891 INFO - Nodes should register to http://192.168.1.48:4444/grid/register/
    16:06:29.891 INFO - Selenium Grid hub is up and running
    
  3. Access the Selenium Grid Hub Console and ensure Selenium Grid Hub is up and running:

    http://localhost:4444/grid/console
    
  4. Start the Selenium Grid Node (by default on port 5555) for Mozilla/GeckoDriver:

    java -Dwebdriver.gecko.driver=geckodriver.exe -jar selenium-server-standalone-3.6.0.jar -role node -hub http://localhost:4444/grid/register
    
  5. Confirm the Selenium Grid Node is registered and started:

    16:15:54.696 INFO - Selenium Grid node is up and ready to register to the hub
    16:15:54.742 INFO - Starting auto registration thread. Will try to register every 5000 ms.
    16:15:54.742 INFO - Registering the node to the hub: http://localhost:4444/grid/register
    16:15:54.975 INFO - The node is registered to the hub and ready to use
    
  6. Execute with the Testcase with DesiredCapabilities as follows:

    self.driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=caps)
    
  7. Observe the console logs ending with the following on successful execution of your Testcase:

    16:23:50.590 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@37ff9771
    16:23:50.590 INFO - Handler thread for session 31a1dcb0-8bed-40fb-acdb-d5be19f03ba2 (firefox): Executing DELETE on /session/31a1dcb0-8bed-40fb-acdb-d5be19f03ba2
     (handler: ServicedSession)
    1506941630595   Marionette      INFO    New connections will no longer be accepted
    

Upvotes: 2

Auro Sarma
Auro Sarma

Reputation: 441

There might be a chance, that your previous Grid configuration on the port 4444 was not closed properly. you just if any process is running with the port 4444 and shutdown it. you can use below commands to know the process which is running and to turn of the process.

C:\Users\username>netstat -o -n -a | findstr 0.0:4444
TCP    0.0.0.0:4444      0.0.0.0:0              LISTENING       3116
C:\Users\username>taskkill /F /PID 3116

Then Reconfigure the Grid and run it may work with port 4444 --all the best.

Upvotes: 0

Tarun Lalwani
Tarun Lalwani

Reputation: 146540

You are passing desired_capabilities which is mostly the Module to the server which is not correct.

driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=desired_capabilities)

Should be

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=DesiredCapabilities.FIREFOX)

Upvotes: 0

Related Questions