【问题标题】:Cannot reach node on virtual machine using Selenium Grid无法使用 Selenium Grid 访问虚拟机上的节点
【发布时间】:2017-04-25 12:16:10
【问题描述】:

我在物理机(Windows 10,RAM 16Gb,x64)上启动了一个集线器
java -jar selenium-server-standalone-2.53.0.jar -role hub port 4444

我还在虚拟机上注册了一个 节点(我使用 VirtualBox:Linux,Ubuntu 16.04.2;i386。基本内存:2048 Mb):
java -jar selenium-server-standalone-2.53.0.jar -role webdriver port 9999 -hub @987654321@

节点从网格控制台可见,但连接失败 无法运行测试。

IDE 中的配置:
WebDriver driver = new RemoteWebDriver(new URL("@987654323@"), capabilities);

运行测试时出错: org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 10.0.2.15:9999 [/10.0.2.15] failed: Connection timed out: connect

物理机地址:172.xx.xxx.248
虚拟机地址:10.0.2.15

【问题讨论】:

  • 您可以登录虚拟机并手动启动浏览器吗?
  • 是的,我可以在虚拟 Linux 机器上的 /usr/bin 目录中手动启动 firefox

标签: selenium grid virtual-machine virtualbox nodes


【解决方案1】:

我找到了解决方案。 VM(在我的情况下为 VirtualBox)应按以下方式配置:

进入设置 -> 网络
1. 附加到应该是'Bridged Adapter'
2. 展开 'Advanced' -> 混杂模式 应该是 'Allow All'

【讨论】:

    【解决方案2】:

    您使用错误的 URL 启动 RemoteWebDriver,您应该为其注册中心 IP,而不是节点 IP。

    WebDriver driver = new RemoteWebDriver(new URL("http://172.xx.xxx.248:4444/wd/hub"), capabilities);
    

    这应该可以解决您的问题。

    【讨论】:

    • 不幸的是,它没有帮助。我收到相同的异常 org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败.... 原因:org.apache.http.conn.HttpHostConnectException: Connect to 172.xx.xxx.248:9998 [/172.xx.xxx .248] 失败:连接被拒绝:连接
    • 你用的是哪个版本的火狐?
    • 虚拟机上的 firefox 版本 - 47.0
    • 也许,原因是 - 我使用的 VM 网络是 NAT。当我更改为桥接适配器时-异常也更改为:org.openqa.selenium.SessionNotCreatedException: Unable to bind to locking port 7054 within 45000 ms
    猜你喜欢
    • 2012-06-01
    • 1970-01-01
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    • 2015-12-06
    • 2014-04-08
    • 2018-01-09
    • 2019-12-01
    相关资源
    最近更新 更多