-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[py][bidi]: add response handlers and network data collectors #16438
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
base: trunk
Are you sure you want to change the base?
[py][bidi]: add response handlers and network data collectors #16438
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
PR Code Suggestions ✨Explore these optional code suggestions:
|
I think data collectors should be managed for the user with the handler registration, let's discuss more. |
It is low-level api, we should treat the spec as is. |
In general we'll want a high level network class accessible directly from the driver, and a network module implementation class, in a bidi namespace, likely(?) private API. I think my issue here is that this class includes implementation details that need to be one level deeper. Everything calling out to sockets or converting things to spec syntax should be one level lower. First we must agree on the high level API, then we can figure out how to split things. |
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.
Great work @navin772
request_id = request_data.get("request") | ||
|
||
# Create a Response object with the response data and request ID | ||
response = Response( |
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.
Do we need/want any of the other fields from the Bidi spec for Response object:
network.ResponseData = {
url: text,
protocol: text,
status: js-uint,
statusText: text,
fromCache: bool,
headers: [network.Header],
mimeType: text,
bytesReceived: js-uint,
headersSize: js-uint / null,
bodySize: js-uint / null,
content: network.ResponseContent,
?authChallenges: [network.AuthChallenge],
}
https://www.w3.org/TR/webdriver-bidi/#type-network-ResponseData
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 think we want every field. Is there any reason we wouldn't?
Looks like this is your test failure
|
@navin772 this is great work. I'll review it more closely soon. I am planning on building functionality for capturing HAR files, and this will be a key piece to enable that. |
User description
🔗 Related Issues
Addresses remaining methods for response handlers for python - #13993
💥 What does this PR do?
add_response_handler
remove_response_handler
clear_response_handlers
continue_response
method.add_data_collector
remove_data_collector
get_data
🔧 Implementation Notes
Initially I started out implementing the data collector feature only, but during testing response handlers were required, thus this PR grew bigger.
💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement, Tests
Description
Adds network response handlers (
add_response_handler
,remove_response_handler
,clear_response_handlers
) for BiDi protocolImplements
continue_response
method for modifying intercepted responsesAdds network data collector support (
add_data_collector
,remove_data_collector
,get_data
)Introduces
BytesValue
,StringValue
, andBase64Value
classes for handling network data encodingAdds comprehensive test coverage for response handlers, data collectors, and their integration
Diagram Walkthrough
File Walkthrough
network.py
Add response handlers, data collectors, and encoding classes
py/selenium/webdriver/common/bidi/network.py
BytesValue
,StringValue
, andBase64Value
classes for network dataencoding
add_response_handler
,remove_response_handler
,clear_response_handlers
)add_data_collector
,remove_data_collector
,get_data
)Response
class withcontinue_response
method for responseinterception
clear_request_handlers
to properly clean up subscriptionsbidi_network_tests.py
Add comprehensive tests for response handlers and data collectors
py/test/selenium/webdriver/common/bidi_network_tests.py
continue_response
method