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

[java] Add convenience for enabling BiDi #14029

Merged
merged 1 commit into from
May 24, 2024
Merged

Conversation

pujagani
Copy link
Contributor

@pujagani pujagani commented May 24, 2024

User description

Related to #13991

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

Add a method to enable BiDi

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

Enhancement, Tests


Description

  • Added enableBiDi method to ChromiumOptions and FirefoxOptions to simplify enabling BiDi by setting the webSocketUrl capability.
  • Updated tests in BiDiSessionCleanUpTest to use the new enableBiDi method.
  • Updated browser configurations in Browser class to use the new enableBiDi method.

Changes walkthrough 📝

Relevant files
Enhancement
ChromiumOptions.java
Add `enableBiDi` method to ChromiumOptions                             

java/src/org/openqa/selenium/chromium/ChromiumOptions.java

  • Added enableBiDi method to set the webSocketUrl capability.
  • Returns the current instance for method chaining.
  • +5/-0     
    FirefoxOptions.java
    Add `enableBiDi` method to FirefoxOptions                               

    java/src/org/openqa/selenium/firefox/FirefoxOptions.java

  • Added enableBiDi method to set the webSocketUrl capability.
  • Returns the current instance for method chaining.
  • +5/-0     
    Tests
    BiDiSessionCleanUpTest.java
    Use `enableBiDi` method in BiDiSessionCleanUpTest               

    java/test/org/openqa/selenium/bidi/BiDiSessionCleanUpTest.java

  • Replaced direct capability setting with enableBiDi method in tests.
  • +2/-2     
    Browser.java
    Use `enableBiDi` method in Browser configurations               

    java/test/org/openqa/selenium/testing/drivers/Browser.java

  • Replaced direct capability setting with enableBiDi method in browser
    configurations.
  • +3/-3     

    💡 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 Review 🔍

    ⏱️ Estimated effort to review [1-5]

    2, because the PR introduces a new method in multiple classes to encapsulate an existing capability setting. The changes are straightforward and localized, but they span multiple files which slightly increases the review effort.

    🧪 Relevant tests

    Yes

    ⚡ Possible issues

    Consistency Issue: The method enableBiDi() sets the capability "webSocketUrl" to true. The naming suggests it should be setting a URL, not a boolean. This could lead to confusion or misuse of the method.

    🔒 Security concerns

    No

    Copy link
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Maintainability
    Extract repeated code for enabling BiDi into a helper method for better readability

    To ensure consistency and readability, consider extracting the repeated code for enabling
    BiDi into a separate helper method within the test class.

    java/test/org/openqa/selenium/bidi/BiDiSessionCleanUpTest.java [39]

    -options.enableBiDi();
    +enableBiDiForOptions(options);
     
    Suggestion importance[1-10]: 7

    Why: The suggestion is valid as it addresses code duplication and improves maintainability by suggesting the extraction of repeated code into a helper method.

    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, @pujagani!

    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.

    2 participants