Skip to content

Add tested Python examples for relative locators - #3018

Open
jaduichirag wants to merge 1 commit into
SeleniumHQ:trunkfrom
jaduichirag:docs/python-relative-locator-examples
Open

jaduichirag wants to merge 1 commit into
SeleniumHQ:trunkfrom
jaduichirag:docs/python-relative-locator-examples

Conversation

@jaduichirag

Copy link
Copy Markdown

Description

Part of #2890.

The Python tab of every example in the Relative Locators section of the Locators page (above, below, to_left_of, to_right_of, near, and chaining) was inline, untested code. This PR moves them into tested examples and references them with gh-codeblock.

  • Added 6 tests to examples/python/tests/elements/test_locators.py, one per relative locator. Each test asserts that the expected element is found.
  • Added examples/python/tests/resources/relative_locators.html, a small page that matches the layout in the documentation diagram (email, password, Cancel, Submit). None of the hosted test pages has these element IDs. Loading the page locally keeps the tests deterministic.
  • Updated the Python tabs in locators.en.md, locators.ja.md, locators.pt-br.md and locators.zh-cn.md. The code shown is unchanged apart from the added find_element line.

Motivation and Context

Issue #2890 asks for inline examples to be moved into tested code files so that the documentation stays correct.

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/elements/test_locators.py -k relative: 6 passed (Selenium 4.54.0, Chrome, Windows).

Move the inline Python snippets in the Relative Locators section
(above, below, to_left_of, to_right_of, near, chaining) into tested
code in examples/python/tests/elements/test_locators.py and reference
them with gh-codeblock in all translations.

Adds a small local HTML page matching the documentation diagram
(email, password, cancel, submit) so the tests are deterministic.

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 8f4a686

@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 →

@CLAassistant

CLAassistant commented Nov 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

2 participants