diff --git a/java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java b/java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java index c58b72531944a..d9d1120891aa9 100644 --- a/java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java +++ b/java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java @@ -17,6 +17,8 @@ package org.openqa.selenium.grid.data; +import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; + import java.io.Serializable; import java.util.Arrays; import java.util.List; @@ -129,13 +131,13 @@ private Boolean initialMatch(Capabilities stereotype, Capabilities capabilities) private Boolean managedDownloadsEnabled(Capabilities stereotype, Capabilities capabilities) { // First lets check if user wanted a Node with managed downloads enabled - Object raw = capabilities.getCapability("se:downloadsEnabled"); + Object raw = capabilities.getCapability(ENABLE_DOWNLOADS); if (raw == null || !Boolean.parseBoolean(raw.toString())) { // User didn't ask. So lets move on to the next matching criteria return true; } // User wants managed downloads enabled to be done on this Node, let's check the stereotype - raw = stereotype.getCapability("se:downloadsEnabled"); + raw = stereotype.getCapability(ENABLE_DOWNLOADS); // Try to match what the user requested return raw != null && Boolean.parseBoolean(raw.toString()); } diff --git a/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java b/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java index bdf76f4a1cea6..6691650c0ac20 100644 --- a/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java +++ b/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java @@ -17,6 +17,8 @@ package org.openqa.selenium.grid.node.config; +import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; + import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableMap; @@ -749,8 +751,7 @@ public Capabilities enhanceStereotype(Capabilities capabilities) { .setCapability("se:noVncPort", noVncPort()); } if (isManagedDownloadsEnabled() && canConfigureDownloadsDir(capabilities)) { - capabilities = - new PersistentCapabilities(capabilities).setCapability("se:downloadsEnabled", true); + capabilities = new PersistentCapabilities(capabilities).setCapability(ENABLE_DOWNLOADS, true); } return capabilities; } diff --git a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java index 73360a0f4d288..8561d77d2e2f5 100644 --- a/java/src/org/openqa/selenium/grid/node/local/LocalNode.java +++ b/java/src/org/openqa/selenium/grid/node/local/LocalNode.java @@ -23,6 +23,7 @@ import static org.openqa.selenium.grid.data.Availability.DRAINING; import static org.openqa.selenium.grid.data.Availability.UP; import static org.openqa.selenium.grid.node.CapabilityResponseEncoder.getEncoder; +import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; import static org.openqa.selenium.remote.HttpSessionId.getSessionId; import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES; import static org.openqa.selenium.remote.RemoteTags.SESSION_ID; @@ -575,7 +576,7 @@ public Either newSession( } private boolean managedDownloadsRequested(Capabilities capabilities) { - Object downloadsEnabled = capabilities.getCapability("se:downloadsEnabled"); + Object downloadsEnabled = capabilities.getCapability(ENABLE_DOWNLOADS); return managedDownloadsEnabled && downloadsEnabled != null && Boolean.parseBoolean(downloadsEnabled.toString()); diff --git a/java/test/org/openqa/selenium/chrome/ChromeOptionsTest.java b/java/test/org/openqa/selenium/chrome/ChromeOptionsTest.java index 7cbece6b253eb..f1cf397e41a8c 100644 --- a/java/test/org/openqa/selenium/chrome/ChromeOptionsTest.java +++ b/java/test/org/openqa/selenium/chrome/ChromeOptionsTest.java @@ -27,6 +27,7 @@ import static org.openqa.selenium.chromium.ChromiumDriverLogLevel.OFF; import static org.openqa.selenium.chromium.ChromiumDriverLogLevel.SEVERE; import static org.openqa.selenium.remote.CapabilityType.ACCEPT_INSECURE_CERTS; +import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; import static org.openqa.selenium.remote.CapabilityType.TIMEOUTS; import java.io.File; @@ -98,7 +99,7 @@ void canAddW3CCompliantOptions() { assertThat(mappedOptions.get("acceptInsecureCerts")).isEqualTo(true); assertThat(mappedOptions.get("pageLoadStrategy")).hasToString("eager"); assertThat(mappedOptions.get("strictFileInteractability")).isEqualTo(true); - assertThat(mappedOptions.get("se:downloadsEnabled")).isEqualTo(true); + assertThat(mappedOptions.get(ENABLE_DOWNLOADS)).isEqualTo(true); Map expectedTimeouts = new HashMap<>(); expectedTimeouts.put("implicit", 1000L); @@ -239,7 +240,8 @@ void mergingOptionsWithMutableCapabilities() { MutableCapabilities one = new MutableCapabilities(); - ChromeOptions options = new ChromeOptions(); + org.openqa.selenium.chrome.ChromeOptions options = + new org.openqa.selenium.chrome.ChromeOptions(); options.addArguments("verbose"); options.addArguments("silent"); options.setExperimentalOption("opt1", "val1"); diff --git a/java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java b/java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java index a75a858cc3d2f..7b5fb5562707a 100644 --- a/java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java +++ b/java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java @@ -18,6 +18,7 @@ package org.openqa.selenium.grid.data; import static org.assertj.core.api.Assertions.assertThat; +import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; import org.junit.jupiter.api.Test; import org.openqa.selenium.Capabilities; @@ -198,7 +199,7 @@ void fullMatchExtensionCaps() { "firefox", CapabilityType.PLATFORM_NAME, Platform.WINDOWS, - "se:downloadsEnabled", + ENABLE_DOWNLOADS, true); Capabilities capabilities = new ImmutableCapabilities( @@ -206,7 +207,7 @@ void fullMatchExtensionCaps() { "firefox", CapabilityType.PLATFORM_NAME, Platform.WINDOWS, - "se:downloadsEnabled", + ENABLE_DOWNLOADS, true); assertThat(slotMatcher.matches(stereotype, capabilities)).isTrue(); } @@ -307,8 +308,7 @@ void matchesBrowser() { @Test void matchDownloadsForRegularTestMatchingAgainstADownloadAwareNode() { Capabilities stereotype = - new ImmutableCapabilities( - CapabilityType.BROWSER_NAME, "chrome", "se:downloadsEnabled", true); + new ImmutableCapabilities(CapabilityType.BROWSER_NAME, "chrome", ENABLE_DOWNLOADS, true); Capabilities capabilities = new ImmutableCapabilities(CapabilityType.BROWSER_NAME, "chrome"); assertThat(slotMatcher.matches(stereotype, capabilities)).isTrue(); } @@ -316,11 +316,9 @@ void matchDownloadsForRegularTestMatchingAgainstADownloadAwareNode() { @Test void matchDownloadsForAutoDownloadTestMatchingAgainstADownloadAwareNode() { Capabilities stereotype = - new ImmutableCapabilities( - CapabilityType.BROWSER_NAME, "chrome", "se:downloadsEnabled", true); + new ImmutableCapabilities(CapabilityType.BROWSER_NAME, "chrome", ENABLE_DOWNLOADS, true); Capabilities capabilities = - new ImmutableCapabilities( - CapabilityType.BROWSER_NAME, "chrome", "se:downloadsEnabled", true); + new ImmutableCapabilities(CapabilityType.BROWSER_NAME, "chrome", ENABLE_DOWNLOADS, true); assertThat(slotMatcher.matches(stereotype, capabilities)).isTrue(); } @@ -328,8 +326,7 @@ void matchDownloadsForAutoDownloadTestMatchingAgainstADownloadAwareNode() { void ensureNoMatchFOrDownloadAwareTestMatchingAgainstOrdinaryNode() { Capabilities stereotype = new ImmutableCapabilities(CapabilityType.BROWSER_NAME, "chrome"); Capabilities capabilities = - new ImmutableCapabilities( - CapabilityType.BROWSER_NAME, "chrome", "se:downloadsEnabled", true); + new ImmutableCapabilities(CapabilityType.BROWSER_NAME, "chrome", ENABLE_DOWNLOADS, true); assertThat(slotMatcher.matches(stereotype, capabilities)).isFalse(); } diff --git a/java/test/org/openqa/selenium/grid/node/NodeTest.java b/java/test/org/openqa/selenium/grid/node/NodeTest.java index b8148ae6526f9..b41a62f2f117e 100644 --- a/java/test/org/openqa/selenium/grid/node/NodeTest.java +++ b/java/test/org/openqa/selenium/grid/node/NodeTest.java @@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.InstanceOfAssertFactories.MAP; import static org.openqa.selenium.json.Json.MAP_TYPE; +import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; import static org.openqa.selenium.remote.http.Contents.string; import static org.openqa.selenium.remote.http.HttpMethod.DELETE; import static org.openqa.selenium.remote.http.HttpMethod.GET; @@ -124,8 +125,8 @@ public void setUp(TestInfo testInfo) throws URISyntaxException { stereotype = new ImmutableCapabilities("browserName", "cheese"); caps = new ImmutableCapabilities("browserName", "cheese"); if (isDownloadsTestCase) { - stereotype = new ImmutableCapabilities("browserName", "chrome", "se:downloadsEnabled", true); - caps = new ImmutableCapabilities("browserName", "chrome", "se:downloadsEnabled", true); + stereotype = new ImmutableCapabilities("browserName", "chrome", ENABLE_DOWNLOADS, true); + caps = new ImmutableCapabilities("browserName", "chrome", ENABLE_DOWNLOADS, true); } uri = new URI("http://localhost:1234"); diff --git a/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java b/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java index 69f1ba30a9ee9..904c3cd158874 100644 --- a/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java +++ b/java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java @@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assumptions.assumeFalse; import static org.junit.jupiter.api.Assumptions.assumeTrue; +import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; import com.google.common.collect.ImmutableMap; import java.io.StringReader; @@ -156,7 +157,7 @@ boolean isDownloadEnabled(WebDriverInfo driver, String customMsg) { .filter(caps -> expected.equalsIgnoreCase(caps.getBrowserName())) .findFirst() .orElseThrow(() -> new AssertionError("Unable to find " + customMsg + " info")); - return Optional.ofNullable(found.getCapability("se:downloadsEnabled")) + return Optional.ofNullable(found.getCapability(ENABLE_DOWNLOADS)) .map(value -> Boolean.parseBoolean(value.toString())) .orElse(Boolean.FALSE); } diff --git a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java index 3f0d7d1d3e8ec..df4130df4ac4c 100644 --- a/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java +++ b/java/test/org/openqa/selenium/grid/router/RemoteWebDriverDownloadTest.java @@ -18,6 +18,7 @@ package org.openqa.selenium.grid.router; import static org.assertj.core.api.Assertions.assertThat; +import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; import static org.openqa.selenium.testing.drivers.Browser.IE; import static org.openqa.selenium.testing.drivers.Browser.SAFARI; @@ -75,8 +76,7 @@ public void setupServers() { options.setEnableDownloads(true); capabilities = - new PersistentCapabilities(browser.getCapabilities()) - .setCapability("se:downloadsEnabled", true); + new PersistentCapabilities(browser.getCapabilities()).setCapability(ENABLE_DOWNLOADS, true); Deployment deployment = DeploymentTypes.STANDALONE.start( @@ -194,7 +194,7 @@ void errorsWhenCapabilityMissing() { Capabilities caps = new PersistentCapabilities(Objects.requireNonNull(browser).getCapabilities()) - .setCapability("se:downloadsEnabled", false); + .setCapability(ENABLE_DOWNLOADS, false); WebDriver driver = new RemoteWebDriver(gridUrl, caps); Assertions.assertThrows( diff --git a/java/test/org/openqa/selenium/grid/router/StressTest.java b/java/test/org/openqa/selenium/grid/router/StressTest.java index faccf8f68e721..2631e35b6f206 100644 --- a/java/test/org/openqa/selenium/grid/router/StressTest.java +++ b/java/test/org/openqa/selenium/grid/router/StressTest.java @@ -21,6 +21,7 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; import java.io.StringReader; import java.util.LinkedList; @@ -123,8 +124,7 @@ void multipleSimultaneousSessions() throws Exception { .oneOf( browser .getCapabilities() - .merge( - new MutableCapabilities(Map.of("se:downloadsEnabled", true)))) + .merge(new MutableCapabilities(Map.of(ENABLE_DOWNLOADS, true)))) .address(server.getUrl()) .build(); diff --git a/java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java b/java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java index 14c8ee3273eff..baf7143b165f3 100644 --- a/java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java +++ b/java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java @@ -25,6 +25,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; +import static org.openqa.selenium.remote.CapabilityType.ENABLE_DOWNLOADS; import static org.openqa.selenium.remote.WebDriverFixture.echoCapabilities; import static org.openqa.selenium.remote.WebDriverFixture.errorResponder; import static org.openqa.selenium.remote.WebDriverFixture.exceptionResponder; @@ -814,7 +815,7 @@ void getDownloadableFilesReturnsType() { WebDriverFixture fixture = new WebDriverFixture( - new ImmutableCapabilities("se:downloadsEnabled", true), + new ImmutableCapabilities(ENABLE_DOWNLOADS, true), echoCapabilities, valueResponder(ImmutableMap.of("names", expectedFiles)));