selenium - 创建 RemoteWebDriver 时传递的 Url/Ip

标签 selenium selenium-webdriver selenium-grid selenium-grid2

在创建 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 基本上有两种用途。

  1. 您可以使用 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/

    相关文章:

    java - 如何使用 selenium 测试下拉菜单中的项目是否按字母顺序排序

    java - WebElement 或 WebDriver 来调用 findElement 方法?

    python - Scraper 不会停止点击下一页按钮

    html - Selenium:选择第一个内部元素

    c# - 在 C# 中使用 Selenium 通过部分 id 查找元素

    selenium - org.openqa.selenium.remote.ProtocolHandshake createSession 信息 : Attempting bi-dialect session with Selenium Grid

    google-chrome - Chrome 浏览器在 chrome 节点 Docker 容器中运行多个 chrome 浏览器时崩溃

    java - NG 和 JUnit 框架的区别??哪个最适合使用 Selenium Web 驱动程序进行测试

    selenium - Allure Reports Team City 插件导致构建只卡在运行测试的构建步骤上

    Selenium remoteWebDriver : connection to selenium-standalone-server fail (driver version unknown)