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

[js] Fix locate nodes BiDi test #14140

Merged
merged 2 commits into from
Jun 20, 2024
Merged

Conversation

pujagani
Copy link
Contributor

@pujagani pujagani commented Jun 17, 2024

User description

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

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

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Bug fix


Description

  • Fixed the BiDi test for locating nodes by removing the enabling of BiDi in Firefox options during driver setup.
  • Adjusted the locateNodes function call to remove an undefined parameter, ensuring proper function execution.

Changes walkthrough 📝

Relevant files
Bug fix
locate_nodes_test.js
Fix BiDi test by adjusting driver setup and function parameters

javascript/node/selenium-webdriver/test/bidi/locate_nodes_test.js

  • Removed enabling BiDi in Firefox options during driver setup.
  • Modified locateNodes function call to remove an undefined parameter.
  • +2/-2     

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

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review [1-5] 2
    🧪 Relevant tests No
    🔒 Security concerns No
    ⚡ Key issues to review Possible Bug:
    The removal of enableBidi() in Firefox options might affect other tests or functionalities that depend on BiDi features. Ensure that this change does not negatively impact other areas of the testing suite.

    Copy link
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Ensure the driver is properly quit in the afterEach hook to avoid resource leaks

    Ensure that the driver is properly quit in the afterEach hook to avoid resource leaks by
    adding await driver.quit() before the hook ends.

    javascript/node/selenium-webdriver/test/bidi/locate_nodes_test.js [39]

     afterEach(async function () {
    +  if (driver) {
    +    await driver.quit();
    +  }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Properly quitting the driver in the afterEach hook is crucial to avoid resource leaks and ensure clean test runs. This suggestion directly addresses a common best practice in test teardown.

    8
    Possible issue
    Add error handling for the locateNodes call to manage potential exceptions

    Add error handling for the locateNodes call to manage potential exceptions and provide
    more informative test failure messages.

    javascript/node/selenium-webdriver/test/bidi/locate_nodes_test.js [181]

    -const elements = await browsingContext.locateNodes(Locator.css('div'), 1, sandbox)
    +let elements;
    +try {
    +  elements = await browsingContext.locateNodes(Locator.css('div'), 1, sandbox);
    +} catch (error) {
    +  assert.fail(`locateNodes failed with error: ${error.message}`);
    +}
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Adding error handling for asynchronous operations like locateNodes is important to manage exceptions and provide clearer failure messages, enhancing test robustness and maintainability.

    7
    Add a timeout to the beforeEach and afterEach hooks to prevent tests from hanging indefinitely

    Consider adding a timeout to the beforeEach and afterEach hooks to avoid potential issues
    with tests hanging indefinitely if the driver setup or teardown takes too long.

    javascript/node/selenium-webdriver/test/bidi/locate_nodes_test.js [35-39]

     beforeEach(async function () {
    +  this.timeout(10000); // 10 seconds timeout
       driver = await env.builder().build()
     })
     
     afterEach(async function () {
    +  this.timeout(10000); // 10 seconds timeout
     
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    Why: Adding a timeout can help prevent tests from hanging, which is a good practice, though not critical as the environment might handle timeouts differently.

    6

    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.

    1 participant