Reputation: 183
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
Upvotes: 1
Views: 1796
Reputation: 14746
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;");
and then use a library such as UADetector for parsing the user agent string. 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.
If you would like to get more customized information from your node, here's what you would need to do:
Hope that helps.
Upvotes: 2