Skip to content

Commit eff4a30

Browse files
asolntsevdiemol
andauthored
[feature] add method RemoteWebDriver.isDownloadsEnabled() (SeleniumHQ#15868)
Co-authored-by: Diego Molina <[email protected]>
1 parent fdbf024 commit eff4a30

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,23 @@ public interface HasDownloads {
3333
* @throws WebDriverException if capability to enable downloads is not set
3434
*/
3535
default void requireDownloadsEnabled(Capabilities capabilities) {
36-
boolean downloadsEnabled = capabilities.is("se:downloadsEnabled");
37-
if (!downloadsEnabled) {
36+
if (!isDownloadsEnabled(capabilities)) {
3837
throw new WebDriverException(
3938
"You must enable downloads in order to work with downloadable files.");
4039
}
4140
}
4241

42+
/**
43+
* Checks if downloads are enabled
44+
*
45+
* @return true if this webdriver has capability "se:downloadsEnabled" = true
46+
*/
47+
boolean isDownloadsEnabled();
48+
49+
static boolean isDownloadsEnabled(Capabilities capabilities) {
50+
return capabilities.is("se:downloadsEnabled");
51+
}
52+
4353
/**
4454
* Gets the downloadable files.
4555
*

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,11 @@ public void removeVirtualAuthenticator(VirtualAuthenticator authenticator) {
649649
Map.of("authenticatorId", authenticator.getId()));
650650
}
651651

652+
@Override
653+
public boolean isDownloadsEnabled() {
654+
return HasDownloads.isDownloadsEnabled(capabilities);
655+
}
656+
652657
/**
653658
* Retrieves the names of the downloadable files.
654659
*

0 commit comments

Comments
 (0)