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]: fix return type and docstring for getDownloadableFiles #15293

Merged

Conversation

navin772
Copy link
Member

@navin772 navin772 commented Feb 17, 2025

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.

Motivation and Context

Fixes #15288

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, Tests


Description

  • Fixed the return type of getDownloadableFiles method to List<String>.

  • Updated the method's JavaDoc to reflect the corrected return type.

  • Added a unit test to verify the return type and behavior of getDownloadableFiles.

  • Ensured proper formatting by running the formatting script.


Changes walkthrough 📝

Relevant files
Bug fix
RemoteWebDriver.java
Corrected JavaDoc for `getDownloadableFiles` method           

java/src/org/openqa/selenium/remote/RemoteWebDriver.java

  • Updated JavaDoc for getDownloadableFiles method to correct the
    description.
  • Changed return type in JavaDoc from Map to List.
  • +2/-2     
    Tests
    RemoteWebDriverUnitTest.java
    Added unit test for `getDownloadableFiles` method               

    java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java

  • Added a new unit test for getDownloadableFiles method.
  • Verified the return type and expected behavior of the method.
  • Ensured the test checks for correct command payload.
  • +17/-0   

    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

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    @navin772 navin772 added the C-java Java Bindings label Feb 17, 2025
    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Add error case test coverage

    Add test case to verify behavior when downloads capability is not enabled, since
    the method throws WebDriverException in that case according to its JavaDoc.

    java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java [811-826]

     @Test
     void getDownloadableFilesReturnsType() {
       List<String> expectedFiles = Arrays.asList("file1.txt", "file2.pdf");
     
       WebDriverFixture fixture =
           new WebDriverFixture(
               new ImmutableCapabilities("se:downloadsEnabled", true),
               echoCapabilities,
               valueResponder(ImmutableMap.of("names", expectedFiles)));
     
       List<String> result = fixture.driver.getDownloadableFiles();
     
       assertThat(result).isInstanceOf(List.class).isEqualTo(expectedFiles);
     
       fixture.verifyCommands(new CommandPayload(DriverCommand.GET_DOWNLOADABLE_FILES, emptyMap()));
     }
     
    +@Test
    +void getDownloadableFilesThrowsWhenDownloadsDisabled() {
    +  WebDriverFixture fixture =
    +      new WebDriverFixture(
    +          new ImmutableCapabilities(),
    +          echoCapabilities);
    +
    +  assertThrows(WebDriverException.class, () -> fixture.driver.getDownloadableFiles());
    +}
    +
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion adds important test coverage for error handling when downloads capability is disabled, which is a documented exception case in the JavaDoc. This helps ensure robust error handling and API contract compliance.

    Medium
    • More

    @navin772 navin772 requested a review from pujagani February 17, 2025 10:21
    Copy link
    Member

    @VietND96 VietND96 left a comment

    Choose a reason for hiding this comment

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

    Currently, implementation returns as List<String>. So, updating docs to be aligned is fine, no regression break.

    @VietND96 VietND96 merged commit 5768601 into SeleniumHQ:trunk Feb 17, 2025
    27 of 34 checks passed
    @navin772 navin772 deleted the fix-getDownloadableFiles-return_type-java branch February 17, 2025 11:38
    sandeepsuryaprasad pushed a commit to sandeepsuryaprasad/selenium that referenced this pull request Mar 23, 2025
    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.

    [🐛 Bug]: get_downloadable_files() returns a list of str, not a dict
    2 participants