selenium icon indicating copy to clipboard operation
selenium copied to clipboard

AbstractCapabilities.abbreviate is truncating DesiredCapabilities values

Open johnbartels opened this issue 8 years ago • 4 comments

While some of the DesiredCapabilities' values are not all that important, there are a few that I wish to NOT have truncated. We add a custom "name" key with a value that is the name of the test being executed. We then scoop up our Hub/Node/Test logs and have them centralized for simplified searching. This truncation was added in 3.1.0 and I am not entirely sure why it was added.

19:13:20.233 INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, ..., loggingPrefs: org.openqa.selenium.logging..., media.navigator.permission.disabled: true, name: tcInHouseSeleniumGridHealth..., platform: WINDOWS

A large number of our tests have prefixes + testnames that exceed the current truncation length (30 chars). I believe this issue could be solved a number of ways:

  1. Do not Truncate the values that were specified in the DesiredCapabilities map
  2. Adjust the length comparison to a greater value (30 seems too low)
  3. Make Truncation optional via hub config file

johnbartels avatar Aug 08 '18 13:08 johnbartels

Hi @johnbartels,

Could you give an example of the capabilities? More concretely, how does the object look like and how do the logs look in the Selenium Grid.

diemol avatar Sep 23 '18 17:09 diemol

The original comment includes an example. For additional clarity, the property 'name' is defined with a value of 'tcInHouseSeleniumGridHealthCheck' and that value is truncated down to 'tcInHouseSeleniumGridHealth...' when the desiredcapabilities are traced out in the 'RequestHandler.process' method. This particular test name is shorter than many of our other test names. This issue leaves us unable to see exactly which test is executing via the use of our centralized logging solution.

johnbartels avatar Sep 24 '18 14:09 johnbartels

Passing things in capabilities that are designed for logs is a risky thing to do: the webdriver spec makes it valid for any browser to refuse to start a session if it sees any key it doesn't recognise. If you have modified grid to pull out those details and do something with them, it feels like that would be better place to log those details.

The next version of selenium will feature distributed tracing, which will help with exactly the use case of "what happened to this session", which is essentially the question being asked.

shs96c avatar Nov 13 '18 16:11 shs96c

Circling back to this, now with distributed tracing it is possible to see all the details per session. Here are some docs showing how this works with the new Grid. https://www.selenium.dev/documentation/en/grid/grid_4/advanced_features/observability/

diemol avatar Feb 04 '21 16:02 diemol