Use hosted page for finder examples - #2776
Conversation
👷 Deploy request for selenium-dev pending review.Visit the deploys page to approve it
|
|
|
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
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