Use hosted page for finder examples - #2776
Conversation
✅ Deploy Preview for selenium-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
PR Summary by QodoUse Selenium hosted locator test page in Finders documentation examples
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Removed gh-codeblock finder examples
|
| {{< tab header="Python" >}} | ||
| driver.get("https://www.selenium.dev/selenium/web/locators_tests/locators.html") | ||
| first_input = driver.find_element(By.CLASS_NAME, "information") |
There was a problem hiding this comment.
1. Removed gh-codeblock finder examples 📘 Rule violation ✧ Quality
The updated Finder examples in finders.en.md were changed to inline code inside tabs (notably Python and Ruby) instead of using gh-codeblock references to executable code under examples/, which contradicts the documentation style/contribution guidance and increases the risk that docs drift from CI-validated runnable examples.
Agent Prompt
## Issue description
The repo’s documentation guidance (style and contributing) expects code examples to live under `examples/` and be pulled into docs via the `gh-codeblock` shortcode so they are executable, versioned, and CI-validated. The Finder examples in `website_and_docs/content/documentation/webdriver/elements/finders.en.md` were changed from `gh-codeblock` references (notably in Python and Ruby tabs) to inline snippets, increasing the likelihood of documentation drifting from the runnable examples.
## Issue Context
Keeping examples inline in the docs breaks the recommended workflow where documentation snippets are sourced directly from the `examples` test files and can be executed in CI, making updates harder to maintain and easier to get out of sync. Update the underlying example tests to reflect the hosted locator page/updated locators as needed, then restore the docs to reference those files via `gh-codeblock` (using `text=true` where required), ensuring referenced line ranges match the updated example files.
## Fix Focus Areas
- website_and_docs/content/documentation/webdriver/elements/finders.en.md[30-56]
- website_and_docs/content/documentation/webdriver/elements/finders.en.md[33-47]
- website_and_docs/content/documentation/about/style.en.md[132-143]
- website_and_docs/content/documentation/about/contributing.en.md[54-68]
- examples/python/tests/elements/test_finders.py[21-40]
- examples/ruby/spec/elements/finders_spec.rb[8-24]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| // Get all input elements in the form | ||
| List<WebElement> elements = element.findElements(By.tagName("input")); | ||
| for (WebElement e : elements) { | ||
| System.out.println(e.getText()); |
There was a problem hiding this comment.
2. Input text prints empty 🐞 Bug ≡ Correctness
In “Find Elements From Element”, the example now locates <input> elements but still prints element text (getText()/text), which is typically empty for inputs, making the runnable example misleading/no-op output.
Agent Prompt
### Issue description
The “Find Elements From Element” examples were changed to locate `<input>` elements, but they still print `getText()`/`.text`, which usually returns an empty string for inputs. This makes the example appear broken even when it successfully finds elements.
### Issue Context
Other docs in this repo demonstrate that the correct way to read what’s in an `<input>` is via the `value` attribute/property.
### Fix Focus Areas
- website_and_docs/content/documentation/webdriver/elements/finders.en.md[330-334]
### Suggested fix
Update the print statement(s) to read the input value instead of text:
- Java: `e.getAttribute("value")`
- Python: `element.get_attribute("value")`
- C#: `e.GetAttribute("value")`
- Ruby: `element.attribute('value')`
- JavaScript: `await e.getAttribute('value')`
- Kotlin: `e.getAttribute("value")`
Alternatively, keep using text output but switch the located elements back to text-bearing elements (e.g., `p`).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
The switch to Selenium's hosted locator test page left the "Find
Elements From Element" examples printing getText()/.text on <input>
elements in all six language tabs, which is always empty since input
content lives in the value attribute, not printed here as
getAttribute("value")/attribute('value').
Also, the Python and Ruby tabs had been converted from gh-codeblock
references into hand-typed inline code, dropping them out of CI
coverage and out of the documented "Creating/Moving Examples"
workflow. Rewrote examples/python/tests/elements/test_finders.py and
examples/ruby/spec/elements/finders_spec.rb into real, asserting
tests against the hosted locators page, and re-wired finders.en.md
(plus the ja/pt-br/zh-cn translations, whose prose and gh-codeblock
line references still pointed at the old vegetable/fruit fixture) to
reference them again.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FfNGQbess9DUXE21PrFEzc
Replaces the Finders doc's illustrative, non-executable inline HTML fixture with Selenium's hosted locator test page, and moves every language's example (Java, Python, C#, Ruby, JavaScript, Kotlin) into examples/ as real, assertion-bearing, CI-runnable tests referenced via gh-codeblock, matching the site's documented "Creating/Moving Examples" workflow. Updates the ja/pt-br/zh-cn translations to match. Credit to Kasturi2004 for the original idea and attempt at this in #2776 (replacing the inline HTML snippet with the hosted locator page). This builds on that starting point: it fixes a bug the original introduced (the "Find Elements From Element" section printed getText()/.text on <input> elements, which is always empty — now reads the value attribute instead), and completes the migration for the languages #2776 left as inline, untested snippets (Java, C#, JavaScript, Kotlin). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FfNGQbess9DUXE21PrFEzc
Replaces the Finders doc's illustrative, non-executable inline HTML fixture with Selenium's hosted locator test page, and moves every language's example (Java, Python, C#, Ruby, JavaScript, Kotlin) into examples/ as real, assertion-bearing, CI-runnable tests referenced via gh-codeblock, matching the site's documented "Creating/Moving Examples" workflow. Updates the ja/pt-br/zh-cn translations to match. Credit to Kasturi2004 for the original idea and attempt at this in #2776 (replacing the inline HTML snippet with the hosted locator page). This builds on that starting point: it fixes a bug the original introduced (the "Find Elements From Element" section printed getText()/.text on <input> elements, which is always empty — now reads the value attribute instead), and completes the migration for the languages #2776 left as inline, untested snippets (Java, C#, JavaScript, Kotlin). Claude-Session: https://claude.ai/code/session_01FfNGQbess9DUXE21PrFEzc Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
|
Superseeded by #2800 |
Description
Replace the inline HTML fixture in the Finders documentation with Selenium’s hosted locator test page.
Update Finder examples to use real elements from:
https://www.selenium.dev/selenium/web/locators_tests/locators.htmlAll existing language tabs remain in place.
Motivation and Context
The prior examples referenced an illustrative HTML fragment that could not be executed. Using Selenium’s hosted test page makes the locator examples concrete and runnable against real elements.
Types of changes
Checklist