在创建 RemoteWebDriver 对象时,我们需要传递 URL 和 DesiredCapability 对象。浏览网络上的不同教程,我发现有些教程传递的是 Node 的 URL,而另一些教程则传递的是 HUB 的 URL。请明确使用 Hub 或 Node Url 中的哪一个。 https://github.com/SeleniumHQ/selenium/wiki/Grid2
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
在本教程和其他教程中,他们使用了节点的 url http://www.guru99.com/introduction-to-selenium-grid.html
最佳答案
RemoteWebDriver 基本上有两种用途。
- 您可以使用 RemoteWebDriver 直接与 Selenium Standalone 对话。此时您将向其传递节点的 IP。 [如果您使用 java -jar selenium-server-standalone.jar 启动独立程序,您可以自己看到这一点]您将看到如下一行。
RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
- 第二种用法是当您尝试与网格对话时。在这种情况下,您始终会在 url 中传递网格的 IP 和端口,即
http://<IP>:<Port>/wd/hub
关于selenium - 创建 RemoteWebDriver 时传递的 Url/Ip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37163292/