selenium - 无法使用 Selenium Grid 访问虚拟机上的节点

标签 selenium grid virtual-machine virtualbox nodes

我在物理机(Windows 10,RAM 16Gb,x64)上启动了一个 hub:
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 <a href="http://172.xx.xxx.248:4444/grid/register" rel="noreferrer noopener nofollow">http://172.xx.xxx.248:4444/grid/register</a>

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

IDE 中的配置:
WebDriver driver = new RemoteWebDriver(new URL("<a href="http://10.0.2.15:9999/wd/hub" rel="noreferrer noopener nofollow">http://10.0.2.15:9999/wd/hub</a>"), 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

最佳答案

我找到了一个解决方案。 VM(在我的例子中是 VirtualBox)应该按以下方式配置:

进入设置 -> 网络
1. Attached to 应该是'Bridged Adapter'
2. 展开'Advanced' -> Promiscuous mode 应该是'Allow All' enter image description here

关于selenium - 无法使用 Selenium Grid 访问虚拟机上的节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43610397/

相关文章:

docker - 在不使用 docker 机器的情况下部署 docker swarm

java - 无法通过 Selenium 和 Java 在 https ://spicejet. com 中选择出发日期

python - 仅在 wxgrid 上删除水平网格线

python - 为战列舰创建和初始化 5x5 网格

html - 为什么此网格中的第三个元素与页面底部对齐?

windows - 使用 hyper-v 与 virtualbox 的性能优势有多大?

macos - 访问虚拟机中的本地站点(vmware fusion、virtualbox 等)

c# - 将 sikuli 包含到 C# webdriver selenium

java - 不安装JDK可以在Selenium Webdriver中编写和运行脚本吗?

java - 如何在嵌入式闪存的网络驱动程序中定位元素