[英]Selenium Grid: How to retrieve node information from HUB programatically?
I am trying to run my selenium code using selenium grid. 我正在尝试使用硒网格运行我的硒代码。 Can someone please tell me how to retrieve system information (Like PC name , OS )of the node using java code
有人可以告诉我如何使用Java代码检索节点的系统信息(例如PC名称,OS)
There are multiple ways of doing it. 有多种实现方法。 The simplest of them would be to parse the user agent of the browser.
其中最简单的方法是解析浏览器的用户代理。 That gives you some basic information.
这为您提供了一些基本信息。
After you have launched the browser on the node via instantiation of RemoteWebDriver, you could simply do String userAgent = (String) driver.executeScript("return navigator.userAgent;");
通过实例化RemoteWebDriver在节点上启动浏览器后,只需执行以下操作:
String userAgent = (String) driver.executeScript("return navigator.userAgent;");
and then use a library such as UADetector for parsing the user agent string. 然后使用UADetector之类的库来解析用户代理字符串。 That should give you some information about the machine such as OS version/flavor, browser version etc.,
这应该为您提供有关机器的一些信息,例如操作系统版本/风味,浏览器版本等,
If apart from this you also want the IP address of the node to which your test was routed to, you can refer to this blog post of mine. 如果除此之外,您还想要将测试路由到的节点的IP地址,则可以参考我的这篇博客文章。
If you would like to get more customized information from your node, here's what you would need to do: 如果您想从您的节点中获取更多的自定义信息,则需要执行以下操作:
Hope that helps. 希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.