Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added locator section for Bug #1393 #1880

Merged
merged 1 commit into from
Aug 22, 2024
Merged

Conversation

shbenzer
Copy link
Contributor

@shbenzer shbenzer commented Aug 21, 2024

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

  • 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

documentation


Description

  • Added a new section "Utilizing Locators" to the documentation in multiple languages.
  • Provided code examples for importing and using the By class in Selenium scripts across different programming languages.
  • Improved code formatting and consistency in existing examples.

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

    Copy link

    netlify bot commented Aug 21, 2024

    👷 Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    🔨 Latest commit 19f216b

    @codiumai-pr-agent-pro codiumai-pr-agent-pro bot added documentation Improvements or additions to documentation Review effort [1-5]: 2 labels Aug 21, 2024
    Copy link
    Contributor

    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

    Copy link
    Contributor

    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]

    -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]

     {{< 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]

     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]

     {{< 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

    Copy link
    Member

    @diemol diemol left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Thank you, @shbenzer!

    @diemol diemol merged commit 7ba611e into SeleniumHQ:trunk Aug 22, 2024
    3 checks passed
    selenium-ci added a commit that referenced this pull request Aug 22, 2024
    added section for ticket 1393
    
    [deploy site] 7ba611e
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    documentation Improvements or additions to documentation Review effort [1-5]: 2
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants