SeleniumHQ / seleniumhq.github.io

Official Selenium website and documentation
https://selenium.dev
Apache License 2.0
1.13k stars 1.32k forks source link

Update _index.en.md with note about using XPATH values in an ID selector #1895

Open Convalytics opened 2 months ago

Convalytics commented 2 months ago

User description

Updated Invalid Selector Exception to note that it can also be caused when inputting an xpath value into an ID-based selector.

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.

Description

Additional error case noting that Invalid Selector Exception can also happen if you use XPATH with an ID selector.

Motivation and Context

I had this issue today because I changed my code to search by XPATH instead of ID, and I forgot to change the type from By.ID to By.XPATH.

Types of changes

Checklist


PR Type

documentation


Description


Changes walkthrough ๐Ÿ“

Relevant files
Documentation
_index.en.md
Update documentation for Invalid Selector Exception causes

website_and_docs/content/documentation/webdriver/troubleshooting/errors/_index.en.md
  • Added a note about using XPATH values in an ID selector.
  • Clarified potential cause of Invalid Selector Exception.
  • +1/-0     

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    netlify[bot] commented 2 months ago

    Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    Latest commit f2c5394fce604bafd118e4a0f20001f16be635d7
    CLAassistant commented 2 months ago

    CLA assistant check
    Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
    You have signed the CLA already but the status is still pending? Let us recheck it.

    codiumai-pr-agent-pro[bot] commented 2 months ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review: 1 ๐Ÿ”ตโšชโšชโšชโšช
    ๐Ÿงช No relevant tests
    ๐Ÿ”’ No security concerns identified
    โšก No key issues to review
    codiumai-pr-agent-pro[bot] commented 2 months ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Add a concrete example to illustrate the misuse of XPATH in an ID selector ___ **Provide a specific example of how an XPATH value might be incorrectly used in an ID
    selector to illustrate the point more clearly.** [website_and_docs/content/documentation/webdriver/troubleshooting/errors/_index.en.md [18]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1895/files#diff-d8713bd094ba75ca3ce0659e13a3158956619dcbb35d5ede1743e90dbee52f9aR18-R18) ```diff -This issue can also arise if you've placed an XPATH value as a parameter to an ID selector. +This issue can also arise if you've placed an XPATH value as a parameter to an ID selector. For example, using `driver.find_element(By.ID, "//input[@name='username']")` instead of `driver.find_element(By.XPATH, "//input[@name='username']")`. ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: The suggestion provides a clear example that enhances understanding of the issue, improving the documentation's clarity and usefulness. However, it addresses a minor enhancement rather than a critical issue.
    7
    shbenzer commented 1 month ago

    Thank you for the contribution @Convalytics! Before we can accept the PR a few things must be done first:

    1. Resolve the requested changes
    2. add your changes to all translations
    3. sign the Contributor License Agreement