Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
404 views
in Technique[技术] by (71.8m points)

python - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...