My java skills are not the biggest, and this code may use some cleanup, but this works for me.
HttpHost host = new HttpHost(yourHubIP, yourHubPort); DefaultHttpClient client = new DefaultHttpClient(); URL testSessionApi = new URL("http://" + yourHubIP + ":" + yourHubPort + "/grid/api/testsession?session=" + driver.getSessionId()); BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", testSessionApi.toExternalForm()); HttpResponse response = client.execute(host,r); JSONObject object = (JSONObject)new JSONParser().parse(EntityUtils.toString(response.getEntity())); String proxyID = object.get("proxyId"));
proxyID contains the IP address of node.
source share