7

I execute my tests under Grid Hub and 3 nodes run on 3 remote computers. In my log I can see the messages in random order posted from all these nodes. In order to analyze the logs I have to sort it by computer name. I tried it in following way (Java):

System.getenv().get("COMPUTERNAME")

But every time it returns the name of computer where Hub is running.

user1
  • 945
  • 2
  • 13
  • 37
Dima Star
  • 154
  • 4
  • 15

1 Answers1

3

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:

  1. Get the session id from your webdriver.
Webdriver.getSessionId();
  1. 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
  1. 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"}
  1. Here is the IP address where current test was/is executed.
"proxyId":"http://10.10.9.3:7777"
Nash N
  • 342
  • 2
  • 17