[🐛 Bug]: [py] BiDi network events: response_started callback gets a dict, response_completed gets a dataclass
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start by reading py/private/bidi_enhancements_manifest.py and the generated network parameter dataclasses, then trace how driver.network.add_event_handler() dispatches callbacks and how _network_handlers.py uses raw params. Check existing BiDi network tests for callback types. Done means callbacks receive a consistent data type across the listed events, with tests covering the affected events and internal handlers still working.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
In the Python bindings, driver.network.add_event_handler() passes different kinds of data to the callback depending on the event:
| Event | Callback receives |
|---|---|
response_started |
dict (camelCase keys, e.g. event["isBlocked"]) |
response_completed |
ResponseCompletedParameters dataclass (snake_case, e.g. event.is_blocked) |
before_request_sent |
BeforeRequestSentParameters dataclass |
before_request (alias) |
dict |
auth_required |
dict |
Expected: consistent callback data for all network events.
Actual: user code has to treat events differently. For example, the docs examples need event["response"]["status"] for one event and event.response["status"] for the next one on the same page.
Cause: py/private/bidi_enhancements_manifest.py adds extra_events entries with "event_class": "dict" for auth_required, before_request and response_started. Because those entries come last in the EVENT_CONFIGS dict literal, they override the CDDL-generated typed entries. The comment explains why:
the generated ResponseStartedParameters dataclass only contains "response", losing "request", "isBlocked" and "intercepts"
That no longer seems to be true. In 4.54.0, the generated dataclasses contain all the base parameters:
ResponseStartedParameters ['response', 'context', 'is_blocked', 'navigation', 'redirect_count', 'request', 'timestamp', 'user_context', 'intercepts']
AuthRequiredParameters ['response', 'context', 'is_blocked', 'navigation', 'redirect_count', 'request', 'timestamp', 'user_context', 'intercepts']
BeforeRequestSentParameters ['initiator', 'context', 'is_blocked', 'navigation', 'redirect_count', 'request', 'timestamp', 'user_context', 'intercepts']
Question: should the public add_event_handler() callbacks receive the typed dataclasses for every event? The internal handler registries in _network_handlers.py could keep using raw params. If maintainers agree on a direction, I'm happy to send a PR.
Reproducible Code
import time
from selenium import webdriver
options = webdriver.ChromeOptions()
options.enable_bidi = True
driver = webdriver.Chrome(options=options)
seen = {}
driver.network.add_event_handler("response_started", lambda e: seen.setdefault("started", type(e)))
driver.network.add_event_handler("response_completed", lambda e: seen.setdefault("completed", type(e)))
driver.get("https://www.selenium.dev/selenium/web/blank.html")
time.sleep(1)
print(seen)
driver.quit()
# Output:
# {'started': <class 'dict'>, 'completed': <class 'selenium.webdriver.common.bidi.network.ResponseCompletedParameters'>}
Debugging Logs
No errors; this is about the type passed to the callback.
- Ngôn ngữ chính
- Java
- Star
- 34.6k
- Fork
- 8.7k
- Merge trung bình
- 1 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 107
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SeleniumHQ/selenium
-
C-py I-defect
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
SeleniumHQ/selenium#18438 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
SeleniumHQ/selenium#18323 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
B-build C-py I-enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
SeleniumHQ/selenium#18435 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[🐛 Bug]: Bindings change the user's options when Selenium Manager supplies a browserCó thể đã có người làm @Liz-Lian đã nhận 2 ngày trước. Đang mởC-dotnet C-java C-nodejs C-py C-rb I-defect
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
SeleniumHQ/selenium#18428 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[🐛 Bug]: [rust] Selenium Manager can return a browser from the cache before it finishes copyingCó thể đã có người làm @Liz-Lian đã nhận 2 ngày trước. Đang mởC-rust I-defect
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
SeleniumHQ/selenium#18427 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SeleniumHQ/selenium
Issue tương tự
-
area-integrations
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
? - Needs Triage bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NVIDIA/cudf-spark-jni#5598 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
oracle/graalvm-reachability-metadata#12264 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[source-facebook-pages] post stream never returns attachments.media_typeCó thể đã có người làm @v-k-data đã nhận hôm nay. Đang mởarea/connectors needs-triage type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] AppSync: GetIntrospectionSchema wraps the schema in JSON instead of returning the raw SDL bodyĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
floci-io/floci#10107 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày