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

标签 selenium selenium-grid

我按如下方式从中心获取 RemoteWebDriver:

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

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

我想记录这个以努力追踪间歇性测试失败。

最佳答案

请引用我的这篇博文,了解如何找出测试路由到的节点 ip 和端口。

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

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

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

现在可以通过图书馆随时使用 talk2grid我 build 的。

关于selenium - 查找我的 selenium-grid 远程驱动程序在哪个节点上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40925012/

相关文章:

selenium - RobotFramework - 将 selenium org.openqa.selenium 添加到我的 JavaLibrary 时出现 ClassNotFound 异常

java - Selenium-Grid:如何使用 `user-extensions.js`

selenium - 如何使用selenium grid启动多个浏览器?

java - 正则表达式未从所有字段中获取正确的值

python - 在 Webelement 中通过 xpath 查找 Selenium

java - 在 selenium webdriver 中,我可以点击保存按钮然后页面被保存但是它没有显示这样的元素错误消息无法继续

javascript - Selenium - 使用 javascript 启用元素在 Jenkins 中不起作用

python - Selenium Webdriver 错误 : "Can' t load the profile"

python - 使用 selenium 打开两个以上选项卡