Skip to content

[refactor] use constant CapabilityType.ENABLE_DOWNLOADS instead of hard-coded value se:downloadsEnabled #15867

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

Conversation

asolntsev
Copy link
Contributor

@asolntsev asolntsev commented Jun 5, 2025

User description

💥 What does this PR do?

This PR replaces hard-coded value se:downloadsEnabled in multiple places by proper constant CapabilityType.ENABLE_DOWNLOADS.

🔧 Implementation Notes

One place could not be replaced: org.openqa.selenium.HasDownloads.
Because it's located in module "selenium-api" which cannot depend on module "selenium-remote" (where HasDownloads is located).

🔄 Types of changes

  • Cleanup (formatting, renaming)

PR Type

Enhancement, Bug fix


Description

  • Replaced hard-coded se:downloadsEnabled with CapabilityType.ENABLE_DOWNLOADS

    • Updated all relevant production and test files
  • Improved code maintainability and consistency

  • Ensured tests use the constant for download capability


Changes walkthrough 📝

Relevant files
Enhancement
3 files
DefaultSlotMatcher.java
Use ENABLE_DOWNLOADS constant for managed downloads capability
+4/-2     
NodeOptions.java
Replace hard-coded downloads capability with constant       
+3/-1     
LocalNode.java
Use ENABLE_DOWNLOADS constant in managed downloads check 
+2/-1     
Tests
7 files
ChromeOptionsTest.java
Update test to use ENABLE_DOWNLOADS constant                         
+3/-2     
DefaultSlotMatcherTest.java
Refactor tests to use ENABLE_DOWNLOADS constant                   
+7/-6     
NodeTest.java
Use ENABLE_DOWNLOADS constant in test capabilities             
+3/-2     
NodeOptionsTest.java
Update test to check downloads capability using constant 
+2/-1     
RemoteWebDriverDownloadTest.java
Use ENABLE_DOWNLOADS constant for download capability in tests
+3/-2     
StressTest.java
Refactor test to use ENABLE_DOWNLOADS constant in capabilities
+2/-1     
RemoteWebDriverUnitTest.java
Use ENABLE_DOWNLOADS constant in remote driver test           
+2/-1     

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    qodo-merge-pro bot commented Jun 5, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Missing Variable

    The ChromeOptions variable 'options' is used before it's declared in the mergingOptionsWithMutableCapabilities test method. This could cause compilation errors.

    options.addArguments("verbose");
    options.addArguments("silent");
    options.setExperimentalOption("opt1", "val1");
    options.setExperimentalOption("opt2", "val4");

    Copy link
    Contributor

    qodo-merge-pro bot commented Jun 5, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Simplify class reference

    Simplify the fully qualified class name to just ChromeOptions since the class is
    already in the same package. Using the fully qualified name makes the code
    unnecessarily verbose and harder to read.

    java/test/org/openqa/selenium/chrome/ChromeOptionsTest.java [243]

    -org.openqa.selenium.chrome.ChromeOptions options = new org.openqa.selenium.chrome.ChromeOptions();
    +ChromeOptions options = new ChromeOptions();
    • Apply / Chat
    Suggestion importance[1-10]: 4

    __

    Why: The suggestion correctly identifies that the fully qualified class name is unnecessary since ChromeOptions is in the same package. This improves code readability and follows Java conventions, though it's a minor style improvement.

    Low
    • Update

    @asolntsev asolntsev requested a review from diemol June 5, 2025 16:41
    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.

    Can you please run the format script?

    ./scripts/format.sh

    @asolntsev asolntsev force-pushed the refactor/use-constant-enable-downloads branch from 57e97fc to b302b78 Compare June 5, 2025 18:02
    @asolntsev
    Copy link
    Contributor Author

    Can you please run the format script?

    ./scripts/format.sh

    Thank you, done.

    @diemol diemol merged commit f86a747 into SeleniumHQ:trunk Jun 6, 2025
    31 checks passed
    @asolntsev asolntsev deleted the refactor/use-constant-enable-downloads branch June 6, 2025 13:46
    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