Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions java/src/org/openqa/selenium/HasDownloads.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,23 @@ public interface HasDownloads {
* @throws WebDriverException if capability to enable downloads is not set
*/
default void requireDownloadsEnabled(Capabilities capabilities) {
boolean downloadsEnabled = capabilities.is("se:downloadsEnabled");
if (!downloadsEnabled) {
if (!isDownloadsEnabled(capabilities)) {
throw new WebDriverException(
"You must enable downloads in order to work with downloadable files.");
}
}

/**
* Checks if downloads are enabled
*
* @return true if this webdriver has capability "se:downloadsEnabled" = true
*/
boolean isDownloadsEnabled();

static boolean isDownloadsEnabled(Capabilities capabilities) {
return capabilities.is("se:downloadsEnabled");
}

/**
* Gets the downloadable files.
*
Expand Down
5 changes: 5 additions & 0 deletions java/src/org/openqa/selenium/remote/RemoteWebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@ public void removeVirtualAuthenticator(VirtualAuthenticator authenticator) {
Map.of("authenticatorId", authenticator.getId()));
}

@Override
public boolean isDownloadsEnabled() {
return HasDownloads.isDownloadsEnabled(capabilities);
}

/**
* Retrieves the names of the downloadable files.
*
Expand Down