-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
[🚀 Feature]: Selenium Manager change outputs #11365
Comments
In my opinion, the log level ( |
Could we make the output computer consumable? E.g. Just print the messages within a JSON blob? |
I was going to say that JSON seems like overkill, but then I got to thinking about how the bindings should convey potential additional information to the user. Real world situation right now: Chrome dev channel doesn't have a compatible chromedriver released yet. The solution we have right now doesn't allow for anything that isn't either an error or the desired value. Maybe JSON is the right answer? |
Out of curiosity, do we have examples of any other command line executable that adds log-like information to its sdout by default? |
At Mozilla we had output that was machine readable. I only suggested JSON as it's simpler that writing our own consumer in each language. You can see an example of the output at Mozilla https://firefoxci.taskcluster-artifacts.net/H6oXKqcQTGy9xwcVmyFh0g/0/public/logs/live_backing.log |
I agree, minimizing logic duplication across languages is the goal. So stdout would be JSON blob & stderr would be string with the issue? The main problem with this, of course, is that it wouldn't look great to a user working with it on the command line directly. Were the tools at Mozilla only consumed by machine? Should there be a flag of some kind to toggle the kind of output? |
Another advantage of JSON is that when we eventually add downloading the browser, we're going to want to output the location of the browser as well... JSON would be a good way to provide data about both driver & browser. |
We can implement a new flag in Selenium Manager (e.g., To implement this, we need to define a format for this JSON. Maybe something like this?
... or alternatively:
Also, we need to decide what to do when unexpected errors (panic in Rust) happen. In that case (code results > 0), the JSON blob is not displayed, and the bindings get both |
Another attempt including output code:
|
I would do something like {
"output": [
{"type": "debug"
"timestamp": 167034423,
"message" : "This is a debug trace"
}
]
} or just as each line needs to be output just do {"type": "debug"
"timestamp": 167034423,
"message" : "This is a debug trace"
} so that as each line is output it can be consumed straight away. |
There is no each line for consumption, really. Selenium sends the command and gets back a bunch of output. Something like this is what would be easiest for bindings to parse:
bindings pseudo code would be:
|
Not 100% with @titusfortner on the contents, but with the format. Seems to me that a JSON with just one level is enough, why would we need to nest messages or an array of messages? |
Here's another attempt at the JSON format, which is very close to what happened on the Rust side: For an ok execution (when resolving a driver correctly): {
"logs": [
{
"level": "WARN",
"timestamp": 1670343174,
"message" : "This is a warning trace"
},
{
"level": "DEBUG",
"timestamp": 167034423,
"message" : "This is a debug trace"
}
],
"result" : {
"code" : 0,
"output" : "/home/boni/.cache/selenium/chromedriver/linux64/106.0.5249.61/chromedriver"
}
} For an error execution (when resolving a driver incorrectly): {
"logs": [
{
"level": "WARN",
"timestamp": 1670343174,
"message" : "This is a warning trace"
},
{
"level": "DEBUG",
"timestamp": 167034423,
"message" : "This is a debug trace"
}
],
"result" : {
"code" : 65,
"output" : "Wrong driver version"
}
} In future operations, if needed, we can change the format of the "result" : {
"code" : 0,
"output" : {
"key1": "value1",
"field2" : "value2"
}
} But for the current feature (i.e., driver management), that format is enough, IMO. |
Ok, this makes sense. We're going to need to iterate over logs regardless, I think, so this is as good as can be expected. One thing to keep in mind is that you can't change the format of the output and maintain backwards compatibility. As long as we're calling it a beta and not releasing it independently, we can do whatever we want. But we need to figure out how we want to handle changes. |
I've been reviewing this. Regarding the latter cases, I mean these:
This output is automatically created by the crate that Selenium Manager uses for parsing the CLI arguments, i.e., clap. I've been reviewing if this behavior can be tuned, but I think it is not possible, or at least, in a simple way. But in any case, these cases are not very relevant IMO since the bindings will not invoke Selenium Manager in that way. Therefore, I propose the following procedure:
What do you think? |
on point 1 it might be better to have an |
I agree with @symonk that we if we intend to build the tool that can be used from command line, let's attempt to do it in a more UNIX way. I can imagine people can use it to copy binaries, append them to the PATH, etc so it would be nice if by default the tool:
At the moment the following is not possible without extra processing of STDOUT to strip away INFO prefix. # use selenium-manager to download driver and make it available globally
driver=$(bin/macos/selenium-manager --driver chromedriver)
export PATH="$(dirname driver):$PATH"
# use selenium-manager to download driver and symlink it to the local directory
bin/macos/selenium-manager --driver chromedriver | xargs -I{} ln -s {} ./chromedriver If we follow these simple rules I suppose it will be the easiest way to use the tool both in the bindings and also as a generic UNIX tool. |
Maybe something in the middle could be as follows:
|
As an update, this was discussed at the Selenium TLC Meeting — https://www.selenium.dev/meetings/2022/tlc-12-08/#proposalsdecisions We agreed that the output flags are the right approach. |
…um Manager (#11365) (#11531) * [rust] Support different output types (logger, json, shell) in Selenium Manager (#11365) * [rust] Honor --debug and --trace flags for JSON output * [rust] Include result code and message in the JSON output * [rust] Include assertion to check if driver exists in output test * [rust] Include assertion for result code from JSON in test * [rust] Remove trailing newline from shell and json output * [rust] Use crate name env instead of hardcoding that name
Complete with #11531. |
Reopening so we can track bindings implementation |
Python implemented through 00a2624 |
With .NET done, we can close this. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature and motivation
@nvborisenko proposes:
@symonk proposes:
My biggest take is that we shouldn't be putting error messages in stdout. I don't like having to remove
INFO\t
from results, especially since it is inconsistent with behavior of--version
.Maybe a compromise is to log the level when
--debug
is turned on, and leave it off otherwise?Usage example
Current behavior
This is stdout with error code 0
This is also stdout with error code 0
This is stdout with error code > 0
This is stderr with error code > 0
stderr with error code > 0
The text was updated successfully, but these errors were encountered: