trial999
trial999

Reputation: 1716

API for getting the selenium nodes status from the grid host

Sorry for the generic question, but is there an api that is available as part of the selenium grid that i can query to find out the current active sessions on the grid. There is an api that uses the Json Wire protocol that enables to query the individual nodes to get the sessions information. However i was wondering if there is one that is tied with the grid machine that i can query to get the sessions information of all nodes. Any help is appreciated. Thanks!

Upvotes: 3

Views: 13467

Answers (1)

Krishnan Mahadevan
Krishnan Mahadevan

Reputation: 14746

Currently there is nothing that lets you query the Grid's internals and figure out all the sessions that are currently running with the Grid.

In a nut shell, below are the APIs that the Grid exposes :

  1. Where did the Hub Route my Test to ? You can get this via the URL (GET REQUEST) http://localhost:4444/grid/api/testsession?session=<SessionIdGoesHere> [ The session id can be obtained via driver.getSessionId() where driver is of type RemoteWebDriver or its sub-classes.
  2. Get the details of the Proxy to which my session was routed to ? You can get this via the URL (GET REQUEST) http://localhost:4444/grid/api/proxy?id=<NodeIdGoesHere> [ NodeId is of the form http://Ip:port and both this can be obtained in the response of (2) ]
  3. Get the Hub's configuration. You can get this via the URL (GET REQUEST) http://localhost:4444/grid/api/hub. If you hit this URL on a hub that runs with Selenium 3.0.1 or higher, you should see the info in terms of free slots and total slots in the JSON response.

Whatever apis the Grid exposes (all the above 3 listed apis), I have basically encapsulated them as a library which you can use [ Its a java library ]

Please take a look at what Talk2Grid has to offer (Maven dependency details and sample code is also available in the github page)

To satisfy your needs, you would basically need to build a servlet and inject it into the Hub and then access the information you are looking for, via this custom servlet. To learn more about how to customize the grid refer here.

Hope that helps

Upvotes: 11

Related Questions