Since you are running the grid (and potentially Jenkins/eclipse) from the Hub machine, system.getenv() will return information from the hub machine and not the node machines.
With Selenium Grid 2, it is pretty simple to get the node name, follow these steps:
- Get the session id from your webdriver.
Webdriver.getSessionId();
Goto the below url.
Replace gridIP
with IP or hostname of your Grid's hub machine.
Replace mySessionId
with session Id that you got from step 1 above.
http://gridIP:4444/grid/api/testsession?session=mySessionId
From the JSON response you can find IP and port number from proxyId field.
Sample JSON response below (see proxyId at the very end):
{"msg":"slot found !","success":true,"session":"xd1215w5-sw53-4bcc-qwa6-7e1214dd6542","internalKey":"q13b2q5x-a21s-5ggt-b6aw-1w1qzr5k0672","inactivityTime":78,"proxyId":"http://10.10.9.3:7777"}
- Here is the IP address where current test was/is executed.
"proxyId":"http://10.10.9.3:7777"