Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse capabilities from console #3

Open
nipafx opened this issue Aug 9, 2018 · 7 comments
Open

Parse capabilities from console #3

nipafx opened this issue Aug 9, 2018 · 7 comments

Comments

@nipafx
Copy link

nipafx commented Aug 9, 2018

In the course of setting up end-to-end tests for my application, I wanted to dynamically determine how many grid nodes there are, so I can run each test once for each node. Since there is no endpoint exposing that information, I ended up parsing the output of /grid/console. See SeleniumGrid::parseCapabilities in this snippet (needs tests and documentation!).

Would you be interested to include that functionality?

@krmahadevan
Copy link
Member

@nicolaiparlog - Thanks for reaching out. Yes we can include that for sure in the library.
Oh btw, in case you weren't aware, I worked on adding some rest end-points to the actual grid itself as part of these two PRs

  1. Enriching Hub Status to include Node info SeleniumHQ/selenium#6127 to include node information.

So now you could do something like GET on http://localhost:4444/grid/api/hub/status?configuration=nodes and you would receive a JSON payload such as

{
  "nodes": [
    {
      "browsers": [
        {
          "browser": "safari",
          "slots": {
            "busy": 0,
            "total": 1
          }
        },
        {
          "browser": "chrome",
          "slots": {
            "busy": 0,
            "total": 5
          }
        },
        {
          "browser": "firefox",
          "slots": {
            "busy": 1,
            "total": 5
          }
        }
      ],
      "id": "http://192.168.1.6:23375"
    }
  ],
  "success": true
}
  1. A Hub API that can query all running sessions. SeleniumHQ/selenium#6158 to get session information from all nodes.

So now you could do something like GET on http://localhost:4444/grid/api/sessions and you would receive a JSON payload such as

{
  "proxies": [
    {
      "id": "http://192.168.1.6:23375",
      "remoteHost": "http://192.168.1.6:23375",
      "sessions": {
        "status": 0,
        "value": [
          {
            "id": "a0cf95c1-446f-6749-afdd-b446546a9714",
            "capabilities": {
              "acceptInsecureCerts": false,
              "browserName": "firefox",
              "browserVersion": "61.0.1",
              "moz:accessibilityChecks": false,
              "moz:headless": false,
              "moz:processID": 47184,
              "moz:profile": "/var/folders/mj/81r6v7nn5lqgqgtfl18spfpw0000gn/T/rust_mozprofile.LHpIaGzYWGwZ",
              "moz:useNonSpecCompliantPointerOrigin": false,
              "moz:webdriverClick": true,
              "pageLoadStrategy": "normal",
              "platformName": "darwin",
              "platformVersion": "17.7.0",
              "rotatable": false,
              "timeouts": {
                "implicit": 0,
                "pageLoad": 300000,
                "script": 30000
              }
            }
          }
        ]
      }
    }
  ],
  "success": true
}

Both these PRs are now part of Selenium 3.14

I have been planning on including support for both these end-points over the weekend.

So let me know if you prefer this newer way of getting that information.

@nipafx
Copy link
Author

nipafx commented Aug 10, 2018

Argh, that would've been much better and more stable than parsing the HTML. 🤣

Although, on my grid (running the selenium/hub:3.14.0-arsenic docker image) http://localhost:4444/grid/api/sessions returns this:

{
    "proxies": [],
    "success": true
}

(I remember trying that one out.)

@krmahadevan
Copy link
Member

krmahadevan commented Aug 10, 2018 via email

@nipafx
Copy link
Author

nipafx commented Aug 10, 2018

I started using Selenium only yesterday, so I'm still a noob. 😊 What's a session and how do I get one?

@krmahadevan
Copy link
Member

krmahadevan commented Aug 10, 2018 via email

@nipafx
Copy link
Author

nipafx commented Aug 10, 2018

Yes, that works and the proxies show up one after another (the tests don't run in parallel). But then I can't use that endpoint to create tests, so I'm limited to http://localhost:4444/grid/api/hub/status?configuration=nodes.

@krmahadevan
Copy link
Member

krmahadevan commented Aug 10, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants