質問

Is it possible to have a selenium hub on one machine and an instance of phantomjs on a different computer that connects to the hub in the same manner as a selenium node?

If I start a selenum hub and an instance of phantomjs on the same machine, I can successfully run tests.

If I start a selenium hub and start a selenium node a different machine and run a test with firefox, the test is executed successfully.

If I start a selenium hub and an instance of phantomjs on a different machine, phantomjs will successfully connect to the hub but refuses the connection when the hub tries to send a test.

Every example of a phantomjs instance connecting to a selenium hub that I've found always shows the phantomjs instance running on the same machine as the hub.

Basic environment info###:

  • both machines are running debian jessie
  • selenium-server-standalone-2.39.0.jar
  • phantomjs version is 1.9.7
  • using python and nose

SCENARIOS AND STARTUP COMMANDS###:

hub and phantomjs on same machine successfully executes tests

java -jar selenium-server-standalone-2.39.0.jar -role hub -timeout=50 -browserTimeout=60 -ensureCleanSession
phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://localhost:4444

hub and node on different machine successfully executes tests with firefox

java -jar selenium-server-standalone-2.39.0.jar -role hub -timeout=50 -browserTimeout=60 -ensureCleanSession
java -jar selenium-server-standalone-2.39.0.jar -role node -hub http://10.3.1.120:4444/grid/register -port 8080 -maxSessions=1

hub and phantomjs on different machines fails to execute tests

java -jar selenium-server-standalone-2.39.0.jar -role hub -timeout=50 -browserTimeout=60 -ensureCleanSession
phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://10.3.1.120:4444
  • server output

    Mar 10, 2014 12:19:57 PM org.openqa.grid.selenium.proxy.DefaultRemoteProxy isAlive
    WARNING: Failed to check status of node: Connection refused
    
  • phantomjs output

    PhantomJS is launching GhostDriver...
    [INFO  - 2014-03-10T16:15:46.149Z] GhostDriver - Main - running on port 8080
    [INFO  - 2014-03-10T16:15:46.150Z] GhostDriver - Main - registering to Selenium HUB 'http://10.3.1.120:4444' using '127.0.0.1:8080'
    [INFO  - 2014-03-10T16:15:46.198Z] HUB Register - register - Registered with grid hub: http://10.3.1.120:4444/ (ok)
    
役に立ちましたか?

解決

Add your IP address for the webdriver parameter along with the port number. This should help resolve the issue. Ex -

phantomjs --webdriver-selenium-grid-hub=http://<Remote_IP_Of_Grid_Hub>:4444 --webdriver=<IP_Of_The_Local_Node>:9301

Basically, if no IP is mentioned in "--webdriver" param, node value is sent as localhost. The hub then looks for requests on localhost port 9301. Since the port 9301 is not open on the hub, connection finally drops & we see error.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top