Get Ip Address of Selenium GRID Node


At some point after using Selenium GRID in a large scale environment (on-premise, not sauce labs), we might feel the need to know the “ip address” of the node that a current session is getting executed. If you are wondering what a GRID is and so on, but want to learn, there is a complete tutorial on how to set up grid, manage multiple browser versions and consume it in a large scale environment – Selenium GRID Helper. This might be due many reasons, some I can think of are

  • So that I can remote login into that machine if the session hangs up and debug further
  • Maybe the node got detached from network, so should inform the network team
  • Be able to ssh into the filesystem to monitor the logs
  • Many others which you can think of — Summary is to help narrow down while debugging

JSONObject to JsonObject

The Selenium API was returning a JSONObject type when POST to get the session url. So the modified code now (not sure when it was changed, but I am using Selenium 2.44.0) is as below.

  1. Copy the below code into a class “”
  2. I assume you have all the necessary jars required
  3. The class has main method, so you can execute it directly
  4. I executed it on my localhost [after the GRID on localhost:4444]
  5. The output i.e. the hostname is “localhost” — you might get a different one based on where you execute this