[feature] add method RemoteWebDriver.isDownloadsEnabled() by asolntsev · Pull Request #15868 · SeleniumHQ/selenium

User description

💥 What does this PR do?

I want to add method RemoteWebDriver.isDownloadsEnabled() which re

🔧 Motivation

I need to check if current webdriver has capability se:downloadsEnabled.

My scenario looks like this:

  public File downloadFile(HasDownloads webdriver) {
    if (webdriver.isDownloadsEnabled()) {
      return webdriver.getDownloadableFiles().get(0);
    }
    else {
        // click element, look into "Downloads" folder etc.
    }
  }

🔄 Types of changes

  • New feature
  • Breaking change
    • any 3-rd party webdrivers that implement HasDownloads, but don't extend RemoteWebDriver, will need to implement method isDownloadsEnabled().

PR Type

Enhancement


Description

  • Add isDownloadsEnabled() method to RemoteWebDriver

  • Require HasDownloads implementors to define isDownloadsEnabled()

  • Refactor download capability check in HasDownloads


Changes walkthrough 📝

Relevant files
Enhancement
HasDownloads.java
Add and refactor downloads-enabled capability checks in HasDownloads

java/src/org/openqa/selenium/HasDownloads.java

  • Add abstract isDownloadsEnabled() method to interface
  • Add static utility for capability check
  • Refactor requireDownloadsEnabled to use new method
  • Update documentation for new method
  • +11/-2   
    RemoteWebDriver.java
    Implement isDownloadsEnabled() in RemoteWebDriver               

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

    • Implement isDownloadsEnabled() using HasDownloads utility
    +4/-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.