Selenium: Cloud providers and Grid could benefit from client bindings sending in version and platform info.

Created on 21 Mar 2018  ·  20Comments  ·  Source: SeleniumHQ/selenium

As a cloud provider, we would absolutely love a key in the new session request that says something like “hi I’m version X.Y of the Java bindings running on macOS 10.13” — along the lines of an HTTP User-Agent. This would help with diagnosing bugs and incompatibilities, especially when dealing with a wide variety of versions of both the client bindings and Selenium server and drivers. For similar reasons, I suspect it might also be useful for Grid to log this info.

I'd be happy to contribute code for this across a bunch of the bindings, if people think it's a good idea and we can agree on where to put it and what the format should be.

I-enhancement

Most helpful comment

So, we'd have things like:

  • User-Agent: selenium//3.14 (java windows)
  • User-Agent: selenium//3.14 (python linux)

Other projects can follow the convention, but they are not Selenium and should change the product name accordingly

  • User-Agent: webdriverio//4.9 (js windows)

All 20 comments

Is it okay to put that information in an HTTP header? Specifically the User-Agent header?

Sure, that would work. Could even tailor the actual User-Agent...

We should probably decide on a standard User-Agent format for the project so we're consistent across the different bindings.

Are we planning to overwrite the User-Agent header which is generated by the underlying HTTP library the bindings use?

I recommend using a new non-standard header (something like Selenium-Client-Ver) for sending the binding version, so that it can be succinct (and unambiguous), plus we don't have to worry about adding content to any existing header(s).

How about: X-Selenium-Version: ${LANGUAGE}[-${COMPONENT}]@${VERSION}

Possible values:

Use multiple values to capture nodes in a grid. For example:

X-Selenium-Version: [email protected],[email protected],[email protected]

indicates a request came from a grid server (v3.8.1), which is forwarding a request from another grid at v3.7, which received the initial request from a client using 3.8.1.

@jleyba I like where you're going with that, but it doesn't add in the OS information as was in the original request. Moreover, I'm not entirely sure how we can get a satisfactory OS information string together that would please everyone.

And let's be very clear here, I'm in favor of this if it is _only_ to be applied on new session requests, and is _optional_, meaning that third parties and intermediate nodes can't depend on it, but could make use of it if and only if it's present.

@jleyba I think putting this in the User-Agent header makes the most sense, and from the local end should be: selenium//${version} (${language} ${platform-family}). That's a little more in line with how the MDN docs suggest a UA string should be formed.

I'm not sure about the concatenation thing, but if we did it, then we'd want to look at the routing headers in emails as an example to follow.

@jimevans UA strings are definitely not things that people should rely on. I'm curious about why you think it should only be for new session requests. Will discuss that with you on IRC.

Would ${platform-family} have any more granularity than what is supported in W3C capabilities? I wouldn't want to send anything more detailed without giving users an easy opt-out.

Platform family ends up matching the suggested default allowed platforms from the spec (macos, windows, linux)

Sounds like User-Agent may be the direction being settled on here, but just in case it's not, FYI X- headers are no longer considered best practice: https://tools.ietf.org/html/rfc6648

${language} doesn't contemplate third-party bindings; there are multiple binding libraries in widespread use for js and PHP, for example. Maybe ${language} ${library}, where official libraries use something like official or selenium as the library name?

Or maybe third-party libraries would change the selenium//${version} part?

@cgoldberg Sincewe are talking about the HTTP communication between the language bindings and WebDriver remote ends, not modifying the UA string between the browser/mobile app and the web server, I’m not sure how that affects sniffing that web apps, even mobile ones would do.

@jimevans my bad :)

@sah I'd suggest other implementations do something based on what we decide here, but it's entirely up to them.

@shs96c Sure, they'll make their own decisions, but it would be nice if what's decided here leaves an easy & obvious way for them to fit gracefully into the format if they so choose.

So, we'd have things like:

  • User-Agent: selenium//3.14 (java windows)
  • User-Agent: selenium//3.14 (python linux)

Other projects can follow the convention, but they are not Selenium and should change the product name accordingly

  • User-Agent: webdriverio//4.9 (js windows)

Looks great to me! Waiting for a thumbs up and I'll get a PR going.

Fixed using @jleyba's format for Java in f3ba82ccb6b9c54bfc9f459c18458c78ba3ca42d

.NET UA string added in a433820.

Ruby merged in 429af62c79c4048d54856a9d4b79d451d98e372a.

Was this page helpful?
0 / 5 - 0 ratings