API for getting the selenium nodes status from the grid host

会有一股神秘感。 提交于 2019-12-08 05:27:08

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/41983811/api-for-getting-the-selenium-nodes-status-from-the-grid-host

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!