Skip to content

Fix typos in two files #1889

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

Merged
merged 2 commits into from
Aug 16, 2025
Merged

Fix typos in two files #1889

merged 2 commits into from
Aug 16, 2025

Conversation

Tuscann
Copy link
Contributor

@Tuscann Tuscann commented Aug 24, 2024

User description

In two files fixed typos and refactor the files.

Fixes #1

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

Motivation and Context

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

enhancement


Description

  • Refactored InformationTest.java and InteractionTest.java to improve code readability and consistency.
  • Fixed indentation, spacing, and formatting issues in both files.
  • Enhanced comments for better clarity and understanding of the code.

Changes walkthrough 📝

Relevant files
Enhancement
InformationTest.java
Refactor and improve readability of InformationTest.java 

examples/java/src/test/java/dev/selenium/elements/InformationTest.java

  • Refactored code for better readability and consistency.
  • Fixed indentation and spacing issues.
  • Improved comments for clarity.
  • +46/-51 
    InteractionTest.java
    Refactor and improve readability of InteractionTest.java 

    examples/java/src/test/java/dev/selenium/elements/InteractionTest.java

  • Refactored code for better readability and consistency.
  • Fixed spacing and formatting issues.
  • Enhanced comments for clarity.
  • +17/-19 

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

    In two files fixed typos and refactor the files.
    
    Fixes SeleniumHQ#1
    Copy link

    netlify bot commented Aug 24, 2024

    Deploy Preview for selenium-dev ready!

    Name Link
    🔨 Latest commit 02efbf6
    🔍 Latest deploy log https://app.netlify.com/projects/selenium-dev/deploys/68a0db5ac502a600083c9270
    😎 Deploy Preview https://deploy-preview-1889--selenium-dev.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify project configuration.

    @CLAassistant
    Copy link

    CLAassistant commented Aug 24, 2024

    CLA assistant check
    All committers have signed the CLA.

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Code Smell
    The informationWithElements method is quite long and could be split into smaller, more focused methods for better readability and maintainability.

    Possible Bug
    The checkInput variable is used before it's declared, which might cause a compilation error.

    Copy link
    Contributor

    qodo-merge-pro bot commented Aug 24, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Use try-with-resources to automatically close the WebDriver

    Consider using a try-with-resources statement to ensure that the WebDriver is closed
    properly, even if an exception occurs during the test execution.

    examples/java/src/test/java/dev/selenium/elements/InformationTest.java [17-64]

    -WebDriver driver = new ChromeDriver();
    -driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
    -// Navigate to Url
    -driver.get("https://www.selenium.dev/selenium/web/inputs.html");
    -...
    -driver.quit();
    +try (WebDriver driver = new ChromeDriver()) {
    +    driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
    +    // Navigate to Url
    +    driver.get("https://www.selenium.dev/selenium/web/inputs.html");
    +    ...
    +    // No need for explicit driver.quit() here
    +}
     
    Suggestion importance[1-10]: 9

    Why: This suggestion is a best practice that ensures the WebDriver is closed properly, even if an exception occurs, improving resource management and reliability of the test.

    9
    Maintainability
    Use a constant for the test URL instead of hardcoding it

    Consider using a constant or a configuration file for the URL instead of hardcoding
    it in the test method.

    examples/java/src/test/java/dev/selenium/elements/InteractionTest.java [11]

    -driver.get("https://www.selenium.dev/selenium/web/inputs.html");
    +private static final String TEST_URL = "https://www.selenium.dev/selenium/web/inputs.html";
    +...
    +driver.get(TEST_URL);
     
    Suggestion importance[1-10]: 8

    Why: This suggestion improves maintainability by avoiding hardcoded values, making it easier to update the URL in the future if needed.

    8
    Enhancement
    Use assertTrue for boolean assertions instead of assertEquals with true
    Suggestion Impact:The commit changed boolean assertions from assertEquals(..., true) to assertTrue(...) for isDisplayed, isEnabled, and isSelected checks.

    code diff:

    +      // isDisplayed
    +      // Get boolean value for is element display
    +      boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
    +      assertTrue(isEmailVisible);
     
    -    // isEnabled
    -    // Returns true if element is enabled else returns false
    -    boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
    -    assertEquals(isEnabledButton, true);
    +      // isEnabled
    +      // returns true if element is enabled else returns false
    +      boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
    +      assertTrue(isEnabledButton);
     
    -    // isSelected
    -    // Returns true if element is checked else returns false
    -    boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
    -    assertEquals(isSelectedCheck, true);
    +      // isSelected
    +      // returns true if element is checked else returns false
    +      boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
    +      assertTrue(isSelectedCheck);

    Replace the boolean literal true with the actual boolean value in the assertions to
    improve readability and make the test more self-explanatory.

    examples/java/src/test/java/dev/selenium/elements/InformationTest.java [24-25]

     boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
    -assertEquals(isEmailVisible, true);
    +assertTrue(isEmailVisible);
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Using assertTrue improves readability and makes the test more self-explanatory, which is a good enhancement for code clarity.

    7
    Use assertFalse for boolean assertions instead of assertEquals with false

    Consider using JUnit's assertFalse method instead of assertEquals when checking if a
    boolean value is false. This improves readability and provides a more specific
    assertion.

    examples/java/src/test/java/dev/selenium/elements/InteractionTest.java [16-17]

    -Boolean isChecked = checkInput.isSelected();
    -assertEquals(isChecked, false);
    +boolean isChecked = checkInput.isSelected();
    +assertFalse(isChecked);
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Using assertFalse enhances readability and provides a more specific assertion, which is a beneficial enhancement for code clarity.

    7

    Copy link

    @A1exKH A1exKH left a comment

    Choose a reason for hiding this comment

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

    LGTM.

    @Tuscann
    Copy link
    Contributor Author

    Tuscann commented Nov 8, 2024

    LGTM.

    I am not sure what is next step this pull request to go in main branch?

    @diemol diemol merged commit e1215de into SeleniumHQ:trunk Aug 16, 2025
    10 checks passed
    selenium-ci added a commit that referenced this pull request Aug 16, 2025
    In two files fixed typos and refactor the files.
    
    Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
    
    [deploy site] e1215de
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    4 participants