-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[py] Add low-level sync API to use DevTools #13977
Conversation
PR Description updated to latest commit (929f205)
|
PR Review 🔍
|
@@ -1017,6 +1020,32 @@ def get_log(self, log_type): | |||
""" | |||
return self.execute(Command.GET_LOG, {"type": log_type})["value"] | |||
|
|||
def start_devtools(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the naming here, any suggestions are welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java calls this getDevTools()
, I am not sure what is the idiomatic fit for Python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to start a devtools session in Java -> devTools.createSession();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method both gets DevTools (loads the proper version) and creates session, then returns both the loaded devtools module and the established connection. start_devtools
is the best possible name I came up with for these 2 operations. We could of course split them into 2 separate methods...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for bidi this should be an implementation detail in the higher level APIs, so not too concerned about it.
PR Code Suggestions ✨
|
self._started = False | ||
self._ws = None | ||
|
||
def execute(self, command): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A general comment that applies to this whole PR - do we want to have typing properly implemented? I'm not familiar with the Python typing system so I did what was the easiest for me. I can re-iterate and add types if that's preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would invest in typing for the BiDi implementation. Not much in the CDP one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types are already available in CDP, the question is should I add types to the WebSocketConnection
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be the priority right now. Focus on getting the hard parts implemented, and we can get help from others on the typing later.
CI Failure Feedback 🧐(Checks updated until commit a4b8fa4)
✨ CI feedback usage guide:The CI feedback tool (
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:
where Configuration options
See more information about the |
2958797
to
690e94f
Compare
@p0deje you can lint with
|
User description
Initial implementation of #13975. This provides a low-level API that:
Once this is merged, I'll work on the subsequent PRs that provide high-level API backed by CDP for now (network interception, log events, basic authentication, etc).
The implementation can also be used to send BiDi commands and subscribe to events once BiDi is implemented in Python (assuming we follow the same pattern as for CDP).
PR Type
Enhancement, Tests
Description
start_devtools
method inwebdriver.py
to establish a WebSocket connection and interact with DevTools.WebSocketConnection
class to manage WebSocket connections, send and receive messages, and handle events.websocket-client
dependency torequirements.txt
.event_class
decorator to addevent_class
attribute to classes.Changes walkthrough 📝
generate.py
Add `event_class` attribute to event classes.
py/generate.py
event_class
attribute to classes decorated withevent_class
decorator.
webdriver.py
Add `start_devtools` method for WebSocket connection to DevTools.
py/selenium/webdriver/remote/webdriver.py
WebSocketConnection
.start_devtools
method to establish WebSocket connection andinteract with DevTools.
_websocket_connection
attribute.websocket_connection.py
Implement `WebSocketConnection` class for WebSocket communication.
py/selenium/webdriver/remote/websocket_connection.py
WebSocketConnection
class to manage WebSocket connections.events, and managing connection state.
devtools_tests.py
Add tests for DevTools WebSocket connection and console logging.
py/test/selenium/webdriver/common/devtools_tests.py
logging.
requirements.txt
Add `websocket-client` dependency.
py/requirements.txt
websocket-client
dependency.