当phantomjs在与selenium hub不同的机器上运行时连接被拒绝 [英] Connection refused when phantomjs is run on different machine than selenium hub

查看:141
本文介绍了当phantomjs在与selenium hub不同的机器上运行时连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在一台计算机上拥有一个硒集线器,并在另一台计算机上拥有一个phantomjs实例,并且该实例以与硒节点相同的方式连接到该集线器?

如果在同一台计算机上启动selenum hub和phantomjs实例,则可以成功运行测试.

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

如果我启动硒集线器并在另一台计算机上启动硒节点,并使用firefox运行测试,则测试将成功执行.

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.

如果我在另一个机器上启动了一个硒集线器和phantomjs实例,phantomjs将成功连接到集线器,但在集线器尝试发送测试时会拒绝连接.

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.

我发现的每个连接到硒集线器的phantomjs实例的每个示例始终显示phantomjs实例与该集线器在同一台计算机上运行.

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.

  • 两台机器都在运行debian jessie
  • selenium-server-standalone-2.39.0.jar
  • phantomjs版本是1.9.7
  • 使用python和鼻子

同一计算机上的集线器和phantomjs 成功执行测试

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

不同计算机上的集线器和节点 使用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

不同计算机上的集线器和phantomjs 无法执行测试

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输出

    • 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)
      

    • 推荐答案

      添加webdriver参数的IP地址以及端口号.这应该有助于解决问题.例如-

      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
      

      基本上,如果在"--webdriver"参数中未提及IP,则节点值将作为localhost发送.然后,集线器在本地主机端口9301上查找请求.由于在集线器上未打开端口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.

      这篇关于当phantomjs在与selenium hub不同的机器上运行时连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆