Skip to content

Conversation

pallavigitwork
Copy link
Member

@pallavigitwork pallavigitwork commented Sep 5, 2025

User description

Thanks for contributing to the Selenium site and documentation!
A PR well described will help maintainers to review and merge it quickly

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, and help reviewers by making them as simple and short as possible.

there was a mistake raised in PR #2221 this PR fixes it.

Description

in the python code, the driver should be element, as we are now fetching all the child 'li' elements inside 'ul' parent element.

Motivation and Context

Fixes #2221

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.

PR Type

Bug fix


Description

  • Fix incorrect variable usage in Python code examples

  • Change driver.find_elements() to element.find_elements()

  • Update documentation across multiple language versions


Diagram Walkthrough

flowchart LR
  A["driver.find_element()"] --> B["element variable"]
  B --> C["element.find_elements()"]
  D["driver.find_elements()"] -.-> C
  D -.-> E["❌ Incorrect usage"]
  C --> F["✅ Correct usage"]
Loading

File Walkthrough

Relevant files
Bug fix
finders.en.md
Fix variable reference in English docs                                     

website_and_docs/content/documentation/webdriver/elements/finders.en.md

  • Changed driver.find_elements() to element.find_elements() in Python
    code example
+1/-1     
finders.ja.md
Fix variable reference in Japanese docs                                   

website_and_docs/content/documentation/webdriver/elements/finders.ja.md

  • Changed driver.find_elements() to element.find_elements() in Python
    code example
+1/-1     
finders.pt-br.md
Fix variable reference in Portuguese docs                               

website_and_docs/content/documentation/webdriver/elements/finders.pt-br.md

  • Changed driver.find_elements() to element.find_elements() in Python
    code example
+1/-1     
finders.zh-cn.md
Fix variable reference in Chinese docs                                     

website_and_docs/content/documentation/webdriver/elements/finders.zh-cn.md

  • Changed driver.find_elements() to element.find_elements() in Python
    code example
+1/-1     

Copy link

netlify bot commented Sep 5, 2025

👷 Deploy request for selenium-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 02f1dbb

Copy link
Contributor

qodo-merge-pro bot commented Sep 5, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2221 - Partially compliant

Compliant requirements:

  • Correct the Python example to use element.find_elements(By.XPATH, './/li').
  • Replace driver.find_elements with element.find_elements in the shown documentation sections.
  • Apply the fix across multiple localized pages (en, ja, pt-br, zh-cn) included in this PR.

Non-compliant requirements:

  • None

Requires further human verification:

  • Confirm no other locales or pages contain the same incorrect snippet outside the ones updated here (e.g., es, de, ru).
  • Render the site to visually verify formatting/indentation and tabs render correctly in all languages.
⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Formatting

Check code block indentation consistency around the inserted line to ensure it renders correctly within tabbed code blocks.

element = driver.find_element(By.XPATH, '//ul')

    # get children of tag 'ul' with tag 'li'
elements  = element.find_elements(By.XPATH, './/li')
for e in elements:
    print(e.text)
Formatting

Verify the whitespace/indentation matches surrounding code to avoid misaligned code rendering in the docs tab.

element = driver.find_element(By.XPATH, '//ul')

    # get children of tag 'ul' with tag 'li'
elements  = element.find_elements(By.XPATH, './/li')
for e in elements:
    print(e.text)
  {{< /tab >}}
Formatting

Ensure consistent indentation and spacing in the code block after changing the call site.

element = driver.find_element(By.XPATH, '//ul')

    # get children of tag 'ul' with tag 'li'
elements  = element.find_elements(By.XPATH, './/li')
for e in elements:
    print(e.text)
  {{< /tab >}}

@pallavigitwork pallavigitwork requested a review from a team September 5, 2025 11:23
Copy link
Contributor

qodo-merge-pro bot commented Sep 5, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Use direct-child XPath

Use a direct-child XPath to match the comment "get children" and avoid selecting
nested descendants. Replace .//li with ./li so only immediate li children of the
ul are returned.

website_and_docs/content/documentation/webdriver/elements/finders.en.md [364]

-elements  = element.find_elements(By.XPATH, './/li')
+elements  = element.find_elements(By.XPATH, './li')
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that using ./li instead of .//li more accurately reflects the comment "get children", as it selects only direct children instead of all descendants. This improves the precision and clarity of the documentation example.

Low
  • More

@pallavigitwork pallavigitwork merged commit daea0ec into SeleniumHQ:trunk Sep 6, 2025
3 checks passed
@pallavigitwork pallavigitwork deleted the Fix2221 branch September 8, 2025 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🚀 Feature]: Documentation: correct code of "get children of tag 'ul' with tag 'li'"
2 participants