Skip to content

Add tested Python examples for BiDi network response events - #3019

Open
jaduichirag wants to merge 1 commit into
SeleniumHQ:trunkfrom
jaduichirag:docs/python-bidi-response-events
Open

jaduichirag wants to merge 1 commit into
SeleniumHQ:trunkfrom
jaduichirag:docs/python-bidi-response-events

Conversation

@jaduichirag

Copy link
Copy Markdown

Description

Part of #2890.

On the WebDriver BiDi Network page, the Python tabs for Response Started and Response Completed showed the "code needed" badge. This PR adds tested examples for both and references them with gh-codeblock.

  • Added test_response_started_event and test_response_completed_event to examples/python/tests/bidi/test_network_commands.py. They follow the Java examples: subscribe with driver.network.add_event_handler(...), navigate, then assert the browsing context, request method and response status.
  • Added both tests to the end of the file so that the line ranges already referenced from the docs don't change.
  • Updated the Python tabs in network.en.md, network.ja.md, network.pt-br.md and network.zh-cn.md.

Note for reviewers: in Selenium 4.54, the response_started callback receives a plain dict, while response_completed receives a ResponseCompletedParameters object. The examples use each one as the binding returns it. The likely cause is a duplicate "response_started" key in Network.EVENT_CONFIGS, which replaces the typed entry with dict. I'm happy to raise this separately in SeleniumHQ/selenium.

Motivation and Context

Issue #2890 asks for the pages listed in llms.txt to have tested examples in every binding.

Types of changes

  • Change to the site (I have double-checked the Netlify deployment, and my changes look good)
  • Code example added (and I also added the example to all translated languages)
  • Improved translation
  • Added new translation (and I also added a notice to each document missing translation)

Checklist

  • I have read the contributing document.
  • I have used hugo to render the site/docs locally and I am sure it works.

How tested

pytest tests/bidi/test_network_commands.py: 10 passed, including the 2 new tests (Selenium 4.54.0, Chrome, Windows).

Fill the Python tabs for "Response Started" and "Response Completed"
on the WebDriver BiDi Network page, which showed the "code needed"
badge. The new tests in examples/python/tests/bidi/test_network_commands.py
mirror the Java examples: subscribe with add_event_handler, navigate,
and assert on the browsing context, request method and response status.

Part of SeleniumHQ#2890
@netlify

netlify Bot commented Nov 26, 2026

Copy link
Copy Markdown

👷 Deploy request for selenium-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit abb6f07

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant