查找我的 selenium-grid 远程驱动程序 运行 在哪个节点上?

Find which node my selenium-grid remote driver is running on?

我从集线器中获取 RemoteWebDriver 如下:

RemoteWebDriver driver = new RemoteWebDriver( 
                                      new URL("http://whatever:4444/wd/hub"),
                                      DesiredCapabilities.internetExplorer() );

有没有办法以编程方式找出远程驱动程序 运行 在网格中的哪个节点?

我想记录它以追踪间歇性测试失败。

请参考我的这篇博客 post 了解如何找出测试路由到的节点 ip 和端口。

博客 post : https://rationaleemotions.wordpress.com/2016/01/15/where-did-my-test-run/

简而言之,这是你需要做的(我分享的博客有详细的解释和所需的代码)

  • 通过 Webdriver.getSessionId()
  • 从 webdriver 获取会话 ID
  • 然后您将从上一步获得的会话 ID 附加到 URL http://localhost:4444/grid/api/testsession?session=(将 localhost 替换为实际的网格 IP/host 并替换 4444 与网格正在监听的端口)并触发 POST 调用。
  • 从 JSON 响应中,您将属性 proxyId 的值解析为 URL 并从中提取 IP 和端口。

现在可以通过我构建的库 talk2grid 随时使用。