-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[🐛 Bug]: Calling start_devtools() in 2 different drivers doesn't work #15816
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
Comments
@victorvianna, thank you for creating this issue. We will troubleshoot it as soon as we can. Selenium Triage Team: remember to follow the Triage Guide |
Also, it seems like the socket URL can even depend on the method? Some methods use webSocketUrl capability, whereas others use se:cdp |
@victorvianna this seems like a bug. New drivers should be able to be created without leftover state from a previous instance.
We should at least set it back to Feel free to submit a PR. |
While implementing, I followed the initial CDP approach which used globals, but if there is a way to refactor to avoid it (I'm not a Python expert), I'm all for it. |
Uh oh!
There was an error while loading. Please reload this page.
Description
Repro
git am
the patch below and run the new test withbazel test py:common-chrome
https://gist.github.com/victorvianna/d3930c0962b8fe322d6341b3f29f1fe5
Expected: works fine
Actual: "local variable 'ws_url' referenced before assignment"
We have concrete cases in Chromium benchmarks where this is a problem.
Root cause
devtools
is a global and thus outlives individualWebDrivers
. Whenstart_devtools()
is called the second time, theif not devtools
block containingws_url
initialization is skippedDiscussion
Having the
devtools
auto-generated module be a global seems conceptually wrong. For one thing, this value depends on the browser version (the protocol changes over time). The least invasive change is probably to turn it into aWebDriver
member like_websocket_connection
.On a separate note, I wonder:
Why was a global used in the first place? Would it be costly to include the module again on every call? Because
bidi_connection()
is doing exactly that ATM (notice how there's noglobal devtools
line in the function)_websocket_connection
a single central websocket, shared with other methods. But why limit to a single socket, why not return a new one on every call? Does the browser not support it? One advantage I could imagine is guaranteeing that WebDriver calls close() when its done, but that's not done right now AFAICTReproducible Code
Debugging Logs
The text was updated successfully, but these errors were encountered: