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.
Using a selenium grid for performance testing gives you the advantage of being able to easily and quickly implement performance tests into your continuous testing environment re-purposing familiar selenium tests as performance tests.
The hub is the central point wherein you load your tests. Nodes are the Selenium instances that will execute the tests that you loaded on the hub.
A Selenium Grid has only one Hub and it is launched on a single machine once. Node − Nodes are the Selenium instances that are attached to the Hub which execute the tests. There can be one or more nodes in a grid which can be of any OS and can contain any of the Selenium supported browsers.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With