SeleniumHQ / seleniumhq.github.io

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

added locator section for Bug #1393 #1880

Closed shbenzer closed 3 weeks ago

shbenzer commented 3 weeks ago

User description

For Bug #1393 , I added a section in Locator Strategies describing how the By class works and how to import/utilize it in selenium scripts in multiple languages

Description

added "Utilizing Locators" section in Locator Strategies for each translation added code examples for importing the by class and using it in FindElement

Motivation and Context

Bug Ticket

Types of changes

Checklist


PR Type

documentation


Description


Changes walkthrough πŸ“

Relevant files
Documentation
locators.en.md
Add "Utilizing Locators" section with examples                     

website_and_docs/content/documentation/webdriver/elements/locators.en.md
  • Added a new section titled "Utilizing Locators".
  • Included code examples for using the By class in various languages.
  • Improved indentation for CSharp and Kotlin examples.
  • +36/-2   
    locators.ja.md
    Add "Utilizing Locators" section with examples                     

    website_and_docs/content/documentation/webdriver/elements/locators.ja.md
  • Added a new section titled "Utilizing Locators".
  • Provided code examples for using the By class in multiple languages.
  • +34/-0   
    locators.pt-br.md
    Add "Utilizing Locators" section with examples                     

    website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md
  • Added a new section titled "Utilizing Locators".
  • Included code examples for using the By class in various languages.
  • +32/-0   
    locators.zh-cn.md
    Add "Utilizing Locators" section with examples                     

    website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md
  • Added a new section titled "Utilizing Locators".
  • Provided code examples for using the By class in multiple languages.
  • +32/-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 3 weeks ago

    Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    Latest commit 19f216bd1a8664bddd7178a2c0ae2fd85f18f110
    codiumai-pr-agent-pro[bot] commented 3 weeks ago

    PR Reviewer Guide πŸ”

    ⏱️ Estimated effort to review: 2 πŸ”΅πŸ”΅βšͺβšͺβšͺ
    πŸ§ͺ No relevant tests
    πŸ”’ No security concerns identified
    ⚑ Key issues to review

    Inconsistent Formatting
    Inconsistent indentation in code examples across different languages Untranslated Content
    New "Utilizing Locators" section is not translated in non-English versions
    codiumai-pr-agent-pro[bot] commented 3 weeks ago

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Improve the clarity and correctness of the explanation for utilizing locators ___ **The explanation for utilizing locators contains a typo and an incomplete sentence.
    Consider revising the text to improve clarity and correctness.** [website_and_docs/content/documentation/webdriver/elements/locators.en.md [335]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1880/files#diff-bad5c08d78f84e8bd7528d1a2a3181973375147d3f8bc5b9678cfce7dbe76aabR335-R335) ```diff -The FindElement makes using locators a breeze! For most languages, all you need to do is utilize `webdriver.common.by.By`, however in others it's as simple as setting a parameter in the FindElement function> +The FindElement method makes using locators a breeze! For most languages, all you need to do is utilize `webdriver.common.by.By`. However, in others, it's as simple as setting a parameter in the FindElement function. ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: Correcting the typo and incomplete sentence enhances the clarity and professionalism of the documentation, which is crucial for user understanding.
    8
    Add explanations for each locator method to provide context and improve understanding ___ **Consider adding a brief explanation or example for each locator method shown in the
    code snippets to provide more context and help users understand when to use each
    method.** [website_and_docs/content/documentation/webdriver/elements/locators.en.md [337-343]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1880/files#diff-bad5c08d78f84e8bd7528d1a2a3181973375147d3f8bc5b9678cfce7dbe76aabR337-R343) ```diff {{< tabpane langEqualsHeader=true >}} {{< badge-examples >}} {{< tab header="Java" >}} + // Using className to locate an element with the CSS class "information" import org.openqa.selenium.By; WebDriver driver = new ChromeDriver(); - driver.findElement(By.className("information")); + driver.findElement(By.className("information")); {{< /tab >}} ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 6 Why: Adding explanations for each locator method would improve user understanding, but the existing examples are functional without them.
    6
    Best practice
    Standardize indentation in code examples for better readability ___ **Consider using consistent indentation for the code examples. Currently, some lines
    are indented with tabs and others with spaces. Standardizing the indentation will
    improve readability and maintainability of the documentation.** [website_and_docs/content/documentation/webdriver/elements/locators.en.md [316-317]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1880/files#diff-bad5c08d78f84e8bd7528d1a2a3181973375147d3f8bc5b9678cfce7dbe76aabR316-R317) ```diff var driver = new ChromeDriver(); - driver.FindElement(By.Xpath("//input[@value='f']")); +driver.FindElement(By.Xpath("//input[@value='f']")); ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: The suggestion to standardize indentation improves readability and maintainability, which is important for documentation clarity, but it is not a critical issue.
    7
    Ensure consistency or explain differences in naming conventions across language examples ___ **Ensure consistency in the code examples across different programming languages. For
    instance, the Python example uses snake_case for method names, while other languages
    use camelCase. Consider standardizing the naming conventions or explaining the
    differences.** [website_and_docs/content/documentation/webdriver/elements/locators.en.md [344-348]](https://github.com/SeleniumHQ/seleniumhq.github.io/pull/1880/files#diff-bad5c08d78f84e8bd7528d1a2a3181973375147d3f8bc5b9678cfce7dbe76aabR344-R348) ```diff {{< tab header="Python" >}} from selenium.webdriver.common.by import By driver = webdriver.Chrome() - driver.find_element(By.CLASS_NAME, "information") + # Note: Python uses snake_case for method names + driver.find_element(By.CLASS_NAME, "information") {{< /tab >}} ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: Highlighting the differences in naming conventions across languages is helpful for users, but it is not essential for the functionality of the examples.
    7