diff --git a/java/src/org/openqa/selenium/chrome/AddHasCasting.java b/java/src/org/openqa/selenium/chrome/AddHasCasting.java index 32b3b2f0447b5..6029b047c8524 100644 --- a/java/src/org/openqa/selenium/chrome/AddHasCasting.java +++ b/java/src/org/openqa/selenium/chrome/AddHasCasting.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.function.Predicate; -import static org.openqa.selenium.remote.BrowserType.CHROME; +import static org.openqa.selenium.remote.Browser.CHROME; @AutoService({AdditionalHttpCommands.class, AugmenterProvider.class}) public class AddHasCasting extends org.openqa.selenium.chromium.AddHasCasting { @@ -45,6 +45,6 @@ GET_CAST_ISSUE_MESSAGE, new CommandInfo("session/:sessionId/goog/cast/get_issue_ @Override public Predicate isApplicable() { - return caps -> CHROME.equals(caps.getBrowserName()); + return CHROME::is; } } diff --git a/java/src/org/openqa/selenium/chrome/AddHasCdp.java b/java/src/org/openqa/selenium/chrome/AddHasCdp.java index 660f6170c07b4..c47418d3fd233 100644 --- a/java/src/org/openqa/selenium/chrome/AddHasCdp.java +++ b/java/src/org/openqa/selenium/chrome/AddHasCdp.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.function.Predicate; -import static org.openqa.selenium.remote.BrowserType.CHROME; +import static org.openqa.selenium.remote.Browser.CHROME; @AutoService({AdditionalHttpCommands.class, AugmenterProvider.class}) public class AddHasCdp extends org.openqa.selenium.chromium.AddHasCdp { @@ -41,6 +41,6 @@ public Map getAdditionalCommands() { @Override public Predicate isApplicable() { - return caps -> CHROME.equals(caps.getBrowserName()); + return CHROME::is; } } diff --git a/java/src/org/openqa/selenium/chrome/ChromeDriverInfo.java b/java/src/org/openqa/selenium/chrome/ChromeDriverInfo.java index ffc3db1fca6bc..060e3330a7e7e 100644 --- a/java/src/org/openqa/selenium/chrome/ChromeDriverInfo.java +++ b/java/src/org/openqa/selenium/chrome/ChromeDriverInfo.java @@ -18,7 +18,6 @@ package org.openqa.selenium.chrome; import com.google.auto.service.AutoService; - import org.openqa.selenium.Capabilities; import org.openqa.selenium.ImmutableCapabilities; import org.openqa.selenium.SessionNotCreatedException; @@ -26,11 +25,12 @@ import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebDriverInfo; import org.openqa.selenium.chromium.ChromiumDriverInfo; -import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.CapabilityType; import java.util.Optional; +import static org.openqa.selenium.remote.Browser.CHROME; + @AutoService(WebDriverInfo.class) public class ChromeDriverInfo extends ChromiumDriverInfo { @@ -41,12 +41,12 @@ public String getDisplayName() { @Override public Capabilities getCanonicalCapabilities() { - return new ImmutableCapabilities(CapabilityType.BROWSER_NAME, BrowserType.CHROME); + return new ImmutableCapabilities(CapabilityType.BROWSER_NAME, CHROME.browserName()); } @Override public boolean isSupporting(Capabilities capabilities) { - return BrowserType.CHROME.equalsIgnoreCase(capabilities.getBrowserName()) || + return CHROME.is(capabilities) || capabilities.getCapability("chromeOptions") != null || capabilities.getCapability("goog:chromeOptions") != null; } diff --git a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java index 5d0d135fc6a17..7f6fd1af96b05 100644 --- a/java/src/org/openqa/selenium/chrome/ChromeDriverService.java +++ b/java/src/org/openqa/selenium/chrome/ChromeDriverService.java @@ -17,13 +17,9 @@ package org.openqa.selenium.chrome; -import static java.util.Collections.unmodifiableList; - import com.google.auto.service.AutoService; - import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.service.DriverService; import java.io.File; @@ -33,6 +29,9 @@ import java.util.List; import java.util.Map; +import static java.util.Collections.unmodifiableList; +import static org.openqa.selenium.remote.Browser.CHROME; + /** * Manages the life and death of a ChromeDriver server. */ @@ -160,7 +159,7 @@ public static class Builder extends DriverService.Builder< public int score(Capabilities capabilities) { int score = 0; - if (BrowserType.CHROME.equals(capabilities.getBrowserName())) { + if (CHROME.is(capabilities.getBrowserName())) { score++; } diff --git a/java/src/org/openqa/selenium/chrome/ChromeOptions.java b/java/src/org/openqa/selenium/chrome/ChromeOptions.java index 0baa8f56d5972..90e66962d74af 100644 --- a/java/src/org/openqa/selenium/chrome/ChromeOptions.java +++ b/java/src/org/openqa/selenium/chrome/ChromeOptions.java @@ -20,9 +20,10 @@ import org.openqa.selenium.Capabilities; import org.openqa.selenium.chromium.ChromiumOptions; import org.openqa.selenium.internal.Require; -import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.CapabilityType; +import static org.openqa.selenium.remote.Browser.CHROME; + /** * Class to manage options specific to {@link ChromeDriver}. * @@ -53,8 +54,7 @@ public class ChromeOptions extends ChromiumOptions { private ChromeDriverLogLevel logLevel; public ChromeOptions() { - - super(CapabilityType.BROWSER_NAME, BrowserType.CHROME, CAPABILITY); + super(CapabilityType.BROWSER_NAME, CHROME.browserName(), CAPABILITY); } public ChromeOptions setLogLevel(ChromeDriverLogLevel logLevel){ diff --git a/java/src/org/openqa/selenium/chromium/AddHasCdp.java b/java/src/org/openqa/selenium/chromium/AddHasCdp.java index c5cd7841da546..1f0d6e79aaf12 100644 --- a/java/src/org/openqa/selenium/chromium/AddHasCdp.java +++ b/java/src/org/openqa/selenium/chromium/AddHasCdp.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.function.Predicate; -import static org.openqa.selenium.chromium.ChromiumDriver.KNOWN_CHROMIUM_BROWSERS; +import static org.openqa.selenium.chromium.ChromiumDriver.IS_CHROMIUM_BROWSER; public abstract class AddHasCdp implements AugmenterProvider, AdditionalHttpCommands { @@ -39,7 +39,7 @@ public abstract class AddHasCdp implements AugmenterProvider, Additional @Override public Predicate isApplicable() { - return caps -> KNOWN_CHROMIUM_BROWSERS.contains(caps.getBrowserName()); + return caps -> IS_CHROMIUM_BROWSER.test(caps.getBrowserName()); } @Override diff --git a/java/src/org/openqa/selenium/chromium/AddHasLaunchApp.java b/java/src/org/openqa/selenium/chromium/AddHasLaunchApp.java index 8f3e2205f0767..3325e9af7642f 100644 --- a/java/src/org/openqa/selenium/chromium/AddHasLaunchApp.java +++ b/java/src/org/openqa/selenium/chromium/AddHasLaunchApp.java @@ -30,7 +30,7 @@ import java.util.Map; import java.util.function.Predicate; -import static org.openqa.selenium.chromium.ChromiumDriver.KNOWN_CHROMIUM_BROWSERS; +import static org.openqa.selenium.chromium.ChromiumDriver.IS_CHROMIUM_BROWSER; @AutoService({AdditionalHttpCommands.class, AugmenterProvider.class}) public class AddHasLaunchApp implements AugmenterProvider, AdditionalHttpCommands { @@ -47,7 +47,7 @@ public Map getAdditionalCommands() { @Override public Predicate isApplicable() { - return caps -> KNOWN_CHROMIUM_BROWSERS.contains(caps.getBrowserName()); + return caps -> IS_CHROMIUM_BROWSER.test(caps.getBrowserName()); } @Override diff --git a/java/src/org/openqa/selenium/chromium/AddHasNetworkConditions.java b/java/src/org/openqa/selenium/chromium/AddHasNetworkConditions.java index cad4122f05e4f..677401cfcf10e 100644 --- a/java/src/org/openqa/selenium/chromium/AddHasNetworkConditions.java +++ b/java/src/org/openqa/selenium/chromium/AddHasNetworkConditions.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.function.Predicate; -import static org.openqa.selenium.chromium.ChromiumDriver.KNOWN_CHROMIUM_BROWSERS; +import static org.openqa.selenium.chromium.ChromiumDriver.IS_CHROMIUM_BROWSER; @AutoService({AdditionalHttpCommands.class, AugmenterProvider.class}) public class AddHasNetworkConditions implements AugmenterProvider, AdditionalHttpCommands { @@ -53,7 +53,7 @@ public Map getAdditionalCommands() { @Override public Predicate isApplicable() { - return caps -> KNOWN_CHROMIUM_BROWSERS.contains(caps.getBrowserName()); + return caps -> IS_CHROMIUM_BROWSER.test(caps.getBrowserName()); } @Override diff --git a/java/src/org/openqa/selenium/chromium/AddHasPermissions.java b/java/src/org/openqa/selenium/chromium/AddHasPermissions.java index 7758cac4e6856..702ef9ce6ae84 100644 --- a/java/src/org/openqa/selenium/chromium/AddHasPermissions.java +++ b/java/src/org/openqa/selenium/chromium/AddHasPermissions.java @@ -30,7 +30,7 @@ import java.util.Map; import java.util.function.Predicate; -import static org.openqa.selenium.chromium.ChromiumDriver.KNOWN_CHROMIUM_BROWSERS; +import static org.openqa.selenium.chromium.ChromiumDriver.IS_CHROMIUM_BROWSER; @AutoService({AdditionalHttpCommands.class, AugmenterProvider.class}) public class AddHasPermissions implements AugmenterProvider, AdditionalHttpCommands { @@ -47,7 +47,7 @@ public Map getAdditionalCommands() { @Override public Predicate isApplicable() { - return caps -> KNOWN_CHROMIUM_BROWSERS.contains(caps.getBrowserName()); + return caps -> IS_CHROMIUM_BROWSER.test(caps.getBrowserName()); } @Override diff --git a/java/src/org/openqa/selenium/chromium/ChromiumDriver.java b/java/src/org/openqa/selenium/chromium/ChromiumDriver.java index cccd09d05555e..48f829d662529 100644 --- a/java/src/org/openqa/selenium/chromium/ChromiumDriver.java +++ b/java/src/org/openqa/selenium/chromium/ChromiumDriver.java @@ -44,6 +44,7 @@ import org.openqa.selenium.logging.EventType; import org.openqa.selenium.logging.HasLogEvents; import org.openqa.selenium.mobile.NetworkConnection; +import org.openqa.selenium.remote.Browser; import org.openqa.selenium.remote.CommandExecutor; import org.openqa.selenium.remote.FileDetector; import org.openqa.selenium.remote.RemoteTouchScreen; @@ -62,9 +63,9 @@ import java.util.function.Supplier; import java.util.logging.Logger; -import static org.openqa.selenium.remote.BrowserType.CHROME; -import static org.openqa.selenium.remote.BrowserType.EDGE; -import static org.openqa.selenium.remote.BrowserType.OPERA; +import static org.openqa.selenium.remote.Browser.CHROME; +import static org.openqa.selenium.remote.Browser.EDGE; +import static org.openqa.selenium.remote.Browser.OPERA; /** * A {@link WebDriver} implementation that controls a Chromium browser running on the local machine. @@ -84,7 +85,10 @@ public class ChromiumDriver extends RemoteWebDriver implements NetworkConnection, WebStorage { - public static final List KNOWN_CHROMIUM_BROWSERS = ImmutableList.of(CHROME, EDGE, OPERA, "msedge"); + public static final Predicate IS_CHROMIUM_BROWSER = name -> + CHROME.is(name) || + EDGE.is(name) || + OPERA.is(name); private static final Logger LOG = Logger.getLogger(ChromiumDriver.class.getName()); private final Capabilities capabilities; diff --git a/java/src/org/openqa/selenium/edge/AddHasCasting.java b/java/src/org/openqa/selenium/edge/AddHasCasting.java index 09b7f1695a577..2e2bccca5498f 100644 --- a/java/src/org/openqa/selenium/edge/AddHasCasting.java +++ b/java/src/org/openqa/selenium/edge/AddHasCasting.java @@ -28,6 +28,8 @@ import java.util.Map; import java.util.function.Predicate; +import static org.openqa.selenium.remote.Browser.EDGE; + @AutoService({AdditionalHttpCommands.class, AugmenterProvider.class}) public class AddHasCasting extends org.openqa.selenium.chromium.AddHasCasting { @@ -45,6 +47,6 @@ public Map getAdditionalCommands() { @Override public Predicate isApplicable() { - return caps -> "msedge".equals(caps.getBrowserName()); + return EDGE::is; } } diff --git a/java/src/org/openqa/selenium/edge/AddHasCdp.java b/java/src/org/openqa/selenium/edge/AddHasCdp.java index 0464d66d8e20e..358a379b35be1 100644 --- a/java/src/org/openqa/selenium/edge/AddHasCdp.java +++ b/java/src/org/openqa/selenium/edge/AddHasCdp.java @@ -28,6 +28,8 @@ import java.util.Map; import java.util.function.Predicate; +import static org.openqa.selenium.remote.Browser.EDGE; + @AutoService({AdditionalHttpCommands.class, AugmenterProvider.class}) public class AddHasCdp extends org.openqa.selenium.chromium.AddHasCdp { @@ -41,6 +43,6 @@ public Map getAdditionalCommands() { @Override public Predicate isApplicable() { - return caps -> "msedge".equals(caps.getBrowserName()); + return EDGE::is; } } diff --git a/java/src/org/openqa/selenium/edge/EdgeDriverInfo.java b/java/src/org/openqa/selenium/edge/EdgeDriverInfo.java index bc01191716d71..90893e4286840 100644 --- a/java/src/org/openqa/selenium/edge/EdgeDriverInfo.java +++ b/java/src/org/openqa/selenium/edge/EdgeDriverInfo.java @@ -17,7 +17,6 @@ package org.openqa.selenium.edge; import com.google.auto.service.AutoService; - import org.openqa.selenium.Capabilities; import org.openqa.selenium.ImmutableCapabilities; import org.openqa.selenium.SessionNotCreatedException; @@ -25,11 +24,11 @@ import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebDriverInfo; import org.openqa.selenium.chromium.ChromiumDriverInfo; -import org.openqa.selenium.remote.BrowserType; import java.util.Objects; import java.util.Optional; +import static org.openqa.selenium.remote.Browser.EDGE; import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME; @AutoService(WebDriverInfo.class) @@ -42,12 +41,12 @@ public String getDisplayName() { @Override public Capabilities getCanonicalCapabilities() { - return new ImmutableCapabilities(BROWSER_NAME, BrowserType.EDGE); + return new ImmutableCapabilities(BROWSER_NAME, EDGE.browserName()); } @Override public boolean isSupporting(Capabilities capabilities) { - return (BrowserType.EDGE.equalsIgnoreCase(capabilities.getBrowserName()) + return (EDGE.is(capabilities.getBrowserName()) || capabilities.getCapability("ms:edgeOptions") != null || capabilities.getCapability("edgeOptions") != null) && diff --git a/java/src/org/openqa/selenium/edge/EdgeDriverService.java b/java/src/org/openqa/selenium/edge/EdgeDriverService.java index 157a0ffaaed4d..0d1c6140e3931 100644 --- a/java/src/org/openqa/selenium/edge/EdgeDriverService.java +++ b/java/src/org/openqa/selenium/edge/EdgeDriverService.java @@ -16,14 +16,9 @@ // under the License. package org.openqa.selenium.edge; -import static java.util.Collections.unmodifiableList; -import static java.util.Collections.unmodifiableMap; - import com.google.auto.service.AutoService; - import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.service.DriverService; import java.io.File; @@ -35,6 +30,10 @@ import java.util.Map; import java.util.Objects; +import static java.util.Collections.unmodifiableList; +import static java.util.Collections.unmodifiableMap; +import static org.openqa.selenium.remote.Browser.EDGE; + /** * Manages the life and death of the EdgeDriver (MicrosoftWebDriver or MSEdgeDriver). */ @@ -122,7 +121,7 @@ public static class Builder extends DriverService.Builder< public int score(Capabilities capabilities) { int score = 0; - if (BrowserType.EDGE.equals(capabilities.getBrowserName())) { + if (EDGE.is(capabilities)) { score++; } diff --git a/java/src/org/openqa/selenium/edge/EdgeOptions.java b/java/src/org/openqa/selenium/edge/EdgeOptions.java index 0e30637c50ac7..c3bae35a96a2e 100644 --- a/java/src/org/openqa/selenium/edge/EdgeOptions.java +++ b/java/src/org/openqa/selenium/edge/EdgeOptions.java @@ -18,9 +18,10 @@ import org.openqa.selenium.Capabilities; import org.openqa.selenium.chromium.ChromiumOptions; -import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.CapabilityType; +import static org.openqa.selenium.remote.Browser.EDGE; + /** * Class to manage options specific to {@link EdgeDriver}. * @@ -54,7 +55,7 @@ public class EdgeOptions extends ChromiumOptions { public static final String CAPABILITY = "ms:edgeOptions"; public EdgeOptions() { - super(CapabilityType.BROWSER_NAME, BrowserType.EDGE, CAPABILITY); + super(CapabilityType.BROWSER_NAME, EDGE.browserName(), CAPABILITY); } @Override diff --git a/java/src/org/openqa/selenium/firefox/AddHasContext.java b/java/src/org/openqa/selenium/firefox/AddHasContext.java index 66b63e0bfc5f5..c00ee79fb17e7 100644 --- a/java/src/org/openqa/selenium/firefox/AddHasContext.java +++ b/java/src/org/openqa/selenium/firefox/AddHasContext.java @@ -30,7 +30,7 @@ import java.util.Map; import java.util.function.Predicate; -import static org.openqa.selenium.remote.BrowserType.FIREFOX; +import static org.openqa.selenium.remote.Browser.FIREFOX; @AutoService({AdditionalHttpCommands.class, AugmenterProvider.class}) public class AddHasContext implements AugmenterProvider, AdditionalHttpCommands { @@ -47,7 +47,7 @@ public Map getAdditionalCommands() { @Override public Predicate isApplicable() { - return caps -> FIREFOX.equals(caps.getBrowserName()); + return FIREFOX::is; } @Override diff --git a/java/src/org/openqa/selenium/firefox/AddHasExtensions.java b/java/src/org/openqa/selenium/firefox/AddHasExtensions.java index 938e5a3b575b2..869adf093faae 100644 --- a/java/src/org/openqa/selenium/firefox/AddHasExtensions.java +++ b/java/src/org/openqa/selenium/firefox/AddHasExtensions.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.function.Predicate; -import static org.openqa.selenium.remote.BrowserType.FIREFOX; +import static org.openqa.selenium.remote.Browser.FIREFOX; @AutoService({AdditionalHttpCommands.class, AugmenterProvider.class}) public class AddHasExtensions implements AugmenterProvider, AdditionalHttpCommands { @@ -50,7 +50,7 @@ public Map getAdditionalCommands() { @Override public Predicate isApplicable() { - return caps -> FIREFOX.equals(caps.getBrowserName()); + return FIREFOX::is; } @Override diff --git a/java/src/org/openqa/selenium/firefox/AddHasFullPageScreenshot.java b/java/src/org/openqa/selenium/firefox/AddHasFullPageScreenshot.java index e027ebb5be315..1b41e9a88764a 100644 --- a/java/src/org/openqa/selenium/firefox/AddHasFullPageScreenshot.java +++ b/java/src/org/openqa/selenium/firefox/AddHasFullPageScreenshot.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.function.Predicate; -import static org.openqa.selenium.remote.BrowserType.FIREFOX; +import static org.openqa.selenium.remote.Browser.FIREFOX; @AutoService({AdditionalHttpCommands.class, AugmenterProvider.class}) public class AddHasFullPageScreenshot implements AugmenterProvider, AdditionalHttpCommands { @@ -48,7 +48,7 @@ public Map getAdditionalCommands() { @Override public Predicate isApplicable() { - return caps -> FIREFOX.equals(caps.getBrowserName()); + return FIREFOX::is; } @Override diff --git a/java/src/org/openqa/selenium/firefox/FirefoxOptions.java b/java/src/org/openqa/selenium/firefox/FirefoxOptions.java index 7bf82cb83974e..91364bb6d925f 100644 --- a/java/src/org/openqa/selenium/firefox/FirefoxOptions.java +++ b/java/src/org/openqa/selenium/firefox/FirefoxOptions.java @@ -21,29 +21,19 @@ import org.openqa.selenium.WebDriverException; import org.openqa.selenium.internal.Require; import org.openqa.selenium.remote.AbstractDriverOptions; -import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.CapabilityType; import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; +import java.util.*; import static java.util.stream.Collectors.toMap; import static org.openqa.selenium.firefox.FirefoxDriver.Capability.BINARY; import static org.openqa.selenium.firefox.FirefoxDriver.Capability.MARIONETTE; import static org.openqa.selenium.firefox.FirefoxDriver.Capability.PROFILE; +import static org.openqa.selenium.remote.Browser.FIREFOX; /** * Manage firefox specific settings in a way that geckodriver can understand. @@ -64,7 +54,7 @@ public class FirefoxOptions extends AbstractDriverOptions { private boolean legacy; public FirefoxOptions() { - setCapability(CapabilityType.BROWSER_NAME, BrowserType.FIREFOX); + setCapability(CapabilityType.BROWSER_NAME, FIREFOX.browserName()); setAcceptInsecureCerts(true); setCapability("moz:debuggerAddress", true); } diff --git a/java/src/org/openqa/selenium/firefox/GeckoDriverInfo.java b/java/src/org/openqa/selenium/firefox/GeckoDriverInfo.java index c26d1619af3e5..1d645fe1b9162 100644 --- a/java/src/org/openqa/selenium/firefox/GeckoDriverInfo.java +++ b/java/src/org/openqa/selenium/firefox/GeckoDriverInfo.java @@ -18,18 +18,17 @@ package org.openqa.selenium.firefox; import com.google.auto.service.AutoService; - import org.openqa.selenium.Capabilities; import org.openqa.selenium.ImmutableCapabilities; import org.openqa.selenium.SessionNotCreatedException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebDriverInfo; -import org.openqa.selenium.remote.BrowserType; import java.util.Optional; import static org.openqa.selenium.firefox.FirefoxDriver.Capability.MARIONETTE; +import static org.openqa.selenium.remote.Browser.FIREFOX; import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME; @AutoService(WebDriverInfo.class) @@ -42,7 +41,7 @@ public String getDisplayName() { @Override public Capabilities getCanonicalCapabilities() { - return new ImmutableCapabilities(BROWSER_NAME, BrowserType.FIREFOX); + return new ImmutableCapabilities(BROWSER_NAME, FIREFOX.browserName()); } @Override @@ -51,7 +50,7 @@ public boolean isSupporting(Capabilities capabilities) { return false; } - if (BrowserType.FIREFOX.equalsIgnoreCase(capabilities.getBrowserName())) { + if (FIREFOX.is(capabilities)) { return true; } diff --git a/java/src/org/openqa/selenium/firefox/GeckoDriverService.java b/java/src/org/openqa/selenium/firefox/GeckoDriverService.java index 4eeff355683f6..f344186d2bd62 100644 --- a/java/src/org/openqa/selenium/firefox/GeckoDriverService.java +++ b/java/src/org/openqa/selenium/firefox/GeckoDriverService.java @@ -17,17 +17,12 @@ package org.openqa.selenium.firefox; -import static java.util.Collections.unmodifiableList; -import static java.util.concurrent.TimeUnit.MILLISECONDS; - import com.google.auto.service.AutoService; import com.google.common.io.ByteStreams; - import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.internal.Require; import org.openqa.selenium.net.PortProber; -import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.service.DriverService; import java.io.File; @@ -39,6 +34,10 @@ import java.util.Map; import java.util.Optional; +import static java.util.Collections.unmodifiableList; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static org.openqa.selenium.remote.Browser.FIREFOX; + /** * Manages the life and death of an GeckoDriver aka 'wires'. */ @@ -151,7 +150,7 @@ public int score(Capabilities capabilities) { int score = 0; - if (BrowserType.FIREFOX.equals(capabilities.getBrowserName())) { + if (FIREFOX.is(capabilities)) { score++; } diff --git a/java/src/org/openqa/selenium/firefox/xpi/XpiDriverInfo.java b/java/src/org/openqa/selenium/firefox/xpi/XpiDriverInfo.java index 51337e5fd7f1f..1ad50d2e28e41 100644 --- a/java/src/org/openqa/selenium/firefox/xpi/XpiDriverInfo.java +++ b/java/src/org/openqa/selenium/firefox/xpi/XpiDriverInfo.java @@ -18,7 +18,6 @@ package org.openqa.selenium.firefox.xpi; import com.google.auto.service.AutoService; - import org.openqa.selenium.Capabilities; import org.openqa.selenium.ImmutableCapabilities; import org.openqa.selenium.SessionNotCreatedException; @@ -27,11 +26,11 @@ import org.openqa.selenium.WebDriverInfo; import org.openqa.selenium.firefox.FirefoxBinary; import org.openqa.selenium.firefox.FirefoxDriver; -import org.openqa.selenium.remote.BrowserType; import java.util.Optional; import static org.openqa.selenium.firefox.FirefoxDriver.Capability.MARIONETTE; +import static org.openqa.selenium.remote.Browser.FIREFOX; import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME; @Deprecated @@ -45,7 +44,7 @@ public String getDisplayName() { @Override public Capabilities getCanonicalCapabilities() { - return new ImmutableCapabilities(BROWSER_NAME, BrowserType.FIREFOX, MARIONETTE, true); + return new ImmutableCapabilities(BROWSER_NAME, FIREFOX.browserName(), MARIONETTE, true); } @Override diff --git a/java/src/org/openqa/selenium/ie/InternetExplorerDriverInfo.java b/java/src/org/openqa/selenium/ie/InternetExplorerDriverInfo.java index 5d3fcac2e7205..4942aa310a330 100644 --- a/java/src/org/openqa/selenium/ie/InternetExplorerDriverInfo.java +++ b/java/src/org/openqa/selenium/ie/InternetExplorerDriverInfo.java @@ -18,17 +18,16 @@ package org.openqa.selenium.ie; import com.google.auto.service.AutoService; - import org.openqa.selenium.Capabilities; import org.openqa.selenium.ImmutableCapabilities; import org.openqa.selenium.SessionNotCreatedException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebDriverInfo; -import org.openqa.selenium.remote.BrowserType; import java.util.Optional; +import static org.openqa.selenium.remote.Browser.IE; import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME; @AutoService(WebDriverInfo.class) @@ -41,12 +40,12 @@ public String getDisplayName() { @Override public Capabilities getCanonicalCapabilities() { - return new ImmutableCapabilities(BROWSER_NAME, BrowserType.IE); + return new ImmutableCapabilities(BROWSER_NAME, IE.browserName()); } @Override public boolean isSupporting(Capabilities capabilities) { - return BrowserType.IE.equalsIgnoreCase(capabilities.getBrowserName()) || + return IE.is(capabilities) || capabilities.getCapability("se:ieOptions") != null; } diff --git a/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java b/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java index 7b1e2b910b390..555e590282704 100644 --- a/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java +++ b/java/src/org/openqa/selenium/ie/InternetExplorerDriverService.java @@ -17,13 +17,9 @@ package org.openqa.selenium.ie; -import static java.util.Collections.unmodifiableList; - import com.google.auto.service.AutoService; - import org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.service.DriverService; import java.io.File; @@ -33,6 +29,9 @@ import java.util.List; import java.util.Map; +import static java.util.Collections.unmodifiableList; +import static org.openqa.selenium.remote.Browser.IE; + /** * Manages the life and death of an IEDriverServer. */ @@ -111,7 +110,7 @@ public static class Builder extends DriverService.Builder< public int score(Capabilities capabilites) { int score = 0; - if (BrowserType.IE.equals(capabilites.getBrowserName())) { + if (IE.is(capabilites)) { score++; } diff --git a/java/src/org/openqa/selenium/ie/InternetExplorerOptions.java b/java/src/org/openqa/selenium/ie/InternetExplorerOptions.java index acfe7e33555b7..4be0e4f7cb4ff 100644 --- a/java/src/org/openqa/selenium/ie/InternetExplorerOptions.java +++ b/java/src/org/openqa/selenium/ie/InternetExplorerOptions.java @@ -17,25 +17,9 @@ package org.openqa.selenium.ie; -import static java.util.stream.Collectors.toList; -import static org.openqa.selenium.ie.InternetExplorerDriver.BROWSER_ATTACH_TIMEOUT; -import static org.openqa.selenium.ie.InternetExplorerDriver.ELEMENT_SCROLL_BEHAVIOR; -import static org.openqa.selenium.ie.InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING; -import static org.openqa.selenium.ie.InternetExplorerDriver.FORCE_CREATE_PROCESS; -import static org.openqa.selenium.ie.InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION; -import static org.openqa.selenium.ie.InternetExplorerDriver.IE_SWITCHES; -import static org.openqa.selenium.ie.InternetExplorerDriver.IE_USE_PER_PROCESS_PROXY; -import static org.openqa.selenium.ie.InternetExplorerDriver.IGNORE_ZOOM_SETTING; -import static org.openqa.selenium.ie.InternetExplorerDriver.INITIAL_BROWSER_URL; -import static org.openqa.selenium.ie.InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS; -import static org.openqa.selenium.ie.InternetExplorerDriver.NATIVE_EVENTS; -import static org.openqa.selenium.ie.InternetExplorerDriver.REQUIRE_WINDOW_FOCUS; -import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME; - +import org.openqa.selenium.Capabilities; import org.openqa.selenium.internal.Require; import org.openqa.selenium.remote.AbstractDriverOptions; -import org.openqa.selenium.Capabilities; -import org.openqa.selenium.remote.BrowserType; import java.time.Duration; import java.util.Arrays; @@ -49,6 +33,22 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static java.util.stream.Collectors.toList; +import static org.openqa.selenium.ie.InternetExplorerDriver.BROWSER_ATTACH_TIMEOUT; +import static org.openqa.selenium.ie.InternetExplorerDriver.ELEMENT_SCROLL_BEHAVIOR; +import static org.openqa.selenium.ie.InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING; +import static org.openqa.selenium.ie.InternetExplorerDriver.FORCE_CREATE_PROCESS; +import static org.openqa.selenium.ie.InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION; +import static org.openqa.selenium.ie.InternetExplorerDriver.IE_SWITCHES; +import static org.openqa.selenium.ie.InternetExplorerDriver.IE_USE_PER_PROCESS_PROXY; +import static org.openqa.selenium.ie.InternetExplorerDriver.IGNORE_ZOOM_SETTING; +import static org.openqa.selenium.ie.InternetExplorerDriver.INITIAL_BROWSER_URL; +import static org.openqa.selenium.ie.InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS; +import static org.openqa.selenium.ie.InternetExplorerDriver.NATIVE_EVENTS; +import static org.openqa.selenium.ie.InternetExplorerDriver.REQUIRE_WINDOW_FOCUS; +import static org.openqa.selenium.remote.Browser.IE; +import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME; + /** * Options for configuring the use of IE. Can be used like so: *
InternetExplorerOptions options = new InternetExplorerOptions()
@@ -91,7 +91,7 @@ public class InternetExplorerOptions extends AbstractDriverOptions ieOptions = new HashMap<>();
 
   public InternetExplorerOptions() {
-    setCapability(BROWSER_NAME, BrowserType.IE);
+    setCapability(BROWSER_NAME, IE.browserName());
     setCapability(IE_OPTIONS, ieOptions);
   }
 
diff --git a/java/src/org/openqa/selenium/opera/OperaDriverInfo.java b/java/src/org/openqa/selenium/opera/OperaDriverInfo.java
index af2d24ef528f6..ca8cfc5969da1 100644
--- a/java/src/org/openqa/selenium/opera/OperaDriverInfo.java
+++ b/java/src/org/openqa/selenium/opera/OperaDriverInfo.java
@@ -25,10 +25,10 @@
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebDriverException;
 import org.openqa.selenium.WebDriverInfo;
-import org.openqa.selenium.remote.BrowserType;
 
 import java.util.Optional;
 
+import static org.openqa.selenium.remote.Browser.OPERA;
 import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;
 
 @AutoService(WebDriverInfo.class)
@@ -41,13 +41,12 @@ public String getDisplayName() {
 
   @Override
   public Capabilities getCanonicalCapabilities() {
-    return new ImmutableCapabilities(BROWSER_NAME, BrowserType.OPERA);
+    return new ImmutableCapabilities(BROWSER_NAME, OPERA.browserName());
   }
 
   @Override
   public boolean isSupporting(Capabilities capabilities) {
-    return BrowserType.OPERA_BLINK.equalsIgnoreCase(capabilities.getBrowserName()) ||
-           BrowserType.OPERA.equalsIgnoreCase(capabilities.getBrowserName());
+    return OPERA.is(capabilities.getBrowserName());
   }
 
   @Override
diff --git a/java/src/org/openqa/selenium/opera/OperaDriverService.java b/java/src/org/openqa/selenium/opera/OperaDriverService.java
index 443965a06e66a..6ea4645e4212c 100644
--- a/java/src/org/openqa/selenium/opera/OperaDriverService.java
+++ b/java/src/org/openqa/selenium/opera/OperaDriverService.java
@@ -17,13 +17,9 @@
 
 package org.openqa.selenium.opera;
 
-import static java.util.Collections.unmodifiableList;
-
 import com.google.auto.service.AutoService;
-
 import org.openqa.selenium.Capabilities;
 import org.openqa.selenium.WebDriverException;
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.service.DriverService;
 
 import java.io.File;
@@ -33,6 +29,9 @@
 import java.util.List;
 import java.util.Map;
 
+import static java.util.Collections.unmodifiableList;
+import static org.openqa.selenium.remote.Browser.OPERA;
+
 /**
  * Manages the life and death of a operadriver server.
  */
@@ -117,11 +116,7 @@ public static class Builder extends DriverService.Builder<
     public int score(Capabilities capabilities) {
       int score = 0;
 
-      if (BrowserType.OPERA_BLINK.equals(capabilities.getBrowserName())) {
-        score++;
-      }
-
-      if (BrowserType.OPERA.equals(capabilities.getBrowserName())) {
+      if (OPERA.is(capabilities)) {
         score++;
       }
 
diff --git a/java/src/org/openqa/selenium/opera/OperaOptions.java b/java/src/org/openqa/selenium/opera/OperaOptions.java
index eb5e0960978f7..9c95cb83a6f92 100644
--- a/java/src/org/openqa/selenium/opera/OperaOptions.java
+++ b/java/src/org/openqa/selenium/opera/OperaOptions.java
@@ -25,18 +25,10 @@
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Base64;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
+import java.util.*;
 
 import static java.util.Collections.unmodifiableList;
-import static org.openqa.selenium.remote.BrowserType.OPERA_BLINK;
+import static org.openqa.selenium.remote.Browser.OPERA;
 import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;
 
 /**
@@ -72,7 +64,7 @@ public class OperaOptions extends AbstractDriverOptions {
   private Map experimentalOptions = new HashMap<>();
 
   public OperaOptions() {
-    setCapability(BROWSER_NAME, OPERA_BLINK);
+    setCapability(BROWSER_NAME, OPERA.browserName());
   }
 
   @Override
diff --git a/java/src/org/openqa/selenium/remote/Browser.java b/java/src/org/openqa/selenium/remote/Browser.java
new file mode 100644
index 0000000000000..bf87aad0d8545
--- /dev/null
+++ b/java/src/org/openqa/selenium/remote/Browser.java
@@ -0,0 +1,75 @@
+// Licensed to the Software Freedom Conservancy (SFC) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The SFC licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.openqa.selenium.remote;
+
+import org.openqa.selenium.Capabilities;
+import org.openqa.selenium.internal.Require;
+
+/**
+ * Used to identify a browser based on its name.
+ */
+public interface Browser {
+
+  String browserName();
+
+  default boolean is(String browserName) {
+    return browserName().equals(browserName);
+  }
+
+  default boolean is(Capabilities caps) {
+    Require.nonNull("Capabilities", caps);
+    return is(caps.getBrowserName());
+  }
+
+  Browser CHROME = () -> "chrome";
+  Browser EDGE = new Browser() {
+    @Override
+    public String browserName() {
+      return "MicrosoftEdge";
+    }
+
+    @Override
+    public boolean is(String browserName) {
+      return browserName().equals(browserName) || "msedge".equals(browserName);
+    }
+  };
+  Browser HTMLUNIT = () -> "htmlunit";
+  Browser IE = () -> "internet explorer";
+  Browser FIREFOX = () -> "firefox";
+  Browser OPERA = new Browser() {
+    @Override
+    public String browserName() {
+      return "opera";
+    }
+
+    @Override
+    public boolean is(String browserName) {
+      return browserName().equals(browserName) || "operablink".equals(browserName);
+    }
+  };
+  Browser SAFARI = new Browser() {
+    @Override
+    public String browserName() {
+      return "safari";
+    }
+
+    public boolean is(String browserName) {
+      return browserName().equals(browserName) || "Safari".equals(browserName);
+    }
+  };
+}
diff --git a/java/src/org/openqa/selenium/remote/BrowserType.java b/java/src/org/openqa/selenium/remote/BrowserType.java
index fd0f4d0e4913b..19ea04f4f288d 100644
--- a/java/src/org/openqa/selenium/remote/BrowserType.java
+++ b/java/src/org/openqa/selenium/remote/BrowserType.java
@@ -19,7 +19,10 @@
 
 /**
  * All the browsers supported by selenium
+ *
+ * @deprecated Prefer to use {@link Browser}
  */
+@Deprecated
 public interface BrowserType {
   String FIREFOX = "firefox";
   String SAFARI = "safari";
diff --git a/java/src/org/openqa/selenium/remote/DesiredCapabilities.java b/java/src/org/openqa/selenium/remote/DesiredCapabilities.java
index 750d76a53393d..78b891bc60fa1 100644
--- a/java/src/org/openqa/selenium/remote/DesiredCapabilities.java
+++ b/java/src/org/openqa/selenium/remote/DesiredCapabilities.java
@@ -17,6 +17,7 @@
 
 package org.openqa.selenium.remote;
 
+import static org.openqa.selenium.remote.Browser.HTMLUNIT;
 import static org.openqa.selenium.remote.CapabilityType.ACCEPT_INSECURE_CERTS;
 import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;
 import static org.openqa.selenium.remote.CapabilityType.PLATFORM;
@@ -112,6 +113,6 @@ public DesiredCapabilities merge(Capabilities extraCapabilities) {
 
   @Deprecated
   public static DesiredCapabilities htmlUnit() {
-    return new DesiredCapabilities(BrowserType.HTMLUNIT, "", Platform.ANY);
+    return new DesiredCapabilities(HTMLUNIT.browserName(), "", Platform.ANY);
   }
 }
diff --git a/java/src/org/openqa/selenium/remote/html5/AddWebStorage.java b/java/src/org/openqa/selenium/remote/html5/AddWebStorage.java
index 1c694c0505f60..de1f4e2cb5bcb 100644
--- a/java/src/org/openqa/selenium/remote/html5/AddWebStorage.java
+++ b/java/src/org/openqa/selenium/remote/html5/AddWebStorage.java
@@ -24,10 +24,10 @@
 
 import java.util.function.Predicate;
 
-import static org.openqa.selenium.remote.BrowserType.CHROME;
-import static org.openqa.selenium.remote.BrowserType.EDGE;
-import static org.openqa.selenium.remote.BrowserType.FIREFOX;
-import static org.openqa.selenium.remote.BrowserType.OPERA;
+import static org.openqa.selenium.remote.Browser.CHROME;
+import static org.openqa.selenium.remote.Browser.EDGE;
+import static org.openqa.selenium.remote.Browser.FIREFOX;
+import static org.openqa.selenium.remote.Browser.OPERA;
 import static org.openqa.selenium.remote.CapabilityType.SUPPORTS_WEB_STORAGE;
 
 public class AddWebStorage implements AugmenterProvider {
@@ -35,10 +35,10 @@ public class AddWebStorage implements AugmenterProvider {
   @Override
   public Predicate isApplicable() {
     return caps ->
-      FIREFOX.equals(caps.getBrowserName()) ||
-      CHROME.equals(caps.getBrowserName()) ||
-      EDGE.equals(caps.getBrowserName()) ||
-      OPERA.equals(caps.getBrowserName()) ||
+      FIREFOX.is(caps) ||
+      CHROME.is(caps) ||
+      EDGE.is(caps) ||
+      OPERA.is(caps) ||
       caps.is(SUPPORTS_WEB_STORAGE);
   }
 
diff --git a/java/src/org/openqa/selenium/remote/server/ActiveSessionFactory.java b/java/src/org/openqa/selenium/remote/server/ActiveSessionFactory.java
index 3c4b145263025..32caf440a9f3a 100644
--- a/java/src/org/openqa/selenium/remote/server/ActiveSessionFactory.java
+++ b/java/src/org/openqa/selenium/remote/server/ActiveSessionFactory.java
@@ -40,14 +40,13 @@
 import java.util.regex.Pattern;
 import java.util.stream.StreamSupport;
 
-import static org.openqa.selenium.remote.BrowserType.CHROME;
-import static org.openqa.selenium.remote.BrowserType.EDGE;
-import static org.openqa.selenium.remote.BrowserType.FIREFOX;
-import static org.openqa.selenium.remote.BrowserType.HTMLUNIT;
-import static org.openqa.selenium.remote.BrowserType.IE;
-import static org.openqa.selenium.remote.BrowserType.OPERA;
-import static org.openqa.selenium.remote.BrowserType.OPERA_BLINK;
-import static org.openqa.selenium.remote.BrowserType.SAFARI;
+import static org.openqa.selenium.remote.Browser.CHROME;
+import static org.openqa.selenium.remote.Browser.EDGE;
+import static org.openqa.selenium.remote.Browser.FIREFOX;
+import static org.openqa.selenium.remote.Browser.HTMLUNIT;
+import static org.openqa.selenium.remote.Browser.IE;
+import static org.openqa.selenium.remote.Browser.OPERA;
+import static org.openqa.selenium.remote.Browser.SAFARI;
 import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;
 
 /**
@@ -82,17 +81,16 @@ public ActiveSessionFactory(Tracer tracer) {
                return marionette instanceof Boolean && !(Boolean) marionette;
              },
              "org.openqa.selenium.firefox.xpi.XpiDriverService")
-        .put(browserName(CHROME), "org.openqa.selenium.chrome.ChromeDriverService")
+        .put(browserName(CHROME.browserName()), "org.openqa.selenium.chrome.ChromeDriverService")
         .put(containsKey("chromeOptions"), "org.openqa.selenium.chrome.ChromeDriverService")
-        .put(browserName(EDGE), "org.openqa.selenium.edge.ChromiumEdgeDriverService")
+        .put(browserName(EDGE.browserName()), "org.openqa.selenium.edge.ChromiumEdgeDriverService")
         .put(containsKey("edgeOptions"), "org.openqa.selenium.edge.ChromiumEdgeDriverService")
-        .put(browserName(FIREFOX), "org.openqa.selenium.firefox.GeckoDriverService")
+        .put(browserName(FIREFOX.browserName()), "org.openqa.selenium.firefox.GeckoDriverService")
         .put(containsKey(Pattern.compile("^moz:.*")), "org.openqa.selenium.firefox.GeckoDriverService")
-        .put(browserName(IE), "org.openqa.selenium.ie.InternetExplorerDriverService")
+        .put(browserName(IE.browserName()), "org.openqa.selenium.ie.InternetExplorerDriverService")
         .put(containsKey("se:ieOptions"), "org.openqa.selenium.ie.InternetExplorerDriverService")
-        .put(browserName(OPERA), "org.openqa.selenium.opera.OperaDriverService")
-        .put(browserName(OPERA_BLINK), "org.openqa.selenium.opera.OperaDriverService")
-        .put(browserName(SAFARI), "org.openqa.selenium.safari.SafariDriverService")
+        .put(browserName(OPERA.browserName()), "org.openqa.selenium.opera.OperaDriverService")
+        .put(browserName(SAFARI.browserName()), "org.openqa.selenium.safari.SafariDriverService")
         .put(containsKey(Pattern.compile("^safari\\..*")), "org.openqa.selenium.safari.SafariDriverService")
         .build()
         .entrySet().stream()
@@ -100,8 +98,8 @@ public ActiveSessionFactory(Tracer tracer) {
         .forEach(e -> builder.add(new ServicedSession.Factory(tracer, e.getKey(), e.getValue())));
 
     // Attempt to bind the htmlunitdriver if it's present.
-    bind(builder, "org.openqa.selenium.htmlunit.HtmlUnitDriver", browserName(HTMLUNIT),
-         new ImmutableCapabilities(BROWSER_NAME, HTMLUNIT));
+    bind(builder, "org.openqa.selenium.htmlunit.HtmlUnitDriver", browserName(HTMLUNIT.browserName()),
+         new ImmutableCapabilities(BROWSER_NAME, HTMLUNIT.browserName()));
 
     this.factories = builder.build();
   }
diff --git a/java/src/org/openqa/selenium/remote/session/ChromeFilter.java b/java/src/org/openqa/selenium/remote/session/ChromeFilter.java
index 59771194ad0be..c0666f79bf0d9 100644
--- a/java/src/org/openqa/selenium/remote/session/ChromeFilter.java
+++ b/java/src/org/openqa/selenium/remote/session/ChromeFilter.java
@@ -17,7 +17,6 @@
 
 package org.openqa.selenium.remote.session;
 
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.CapabilityType;
 
 import java.util.Map;
@@ -25,13 +24,15 @@
 import java.util.TreeMap;
 import java.util.stream.Collectors;
 
+import static org.openqa.selenium.remote.Browser.CHROME;
+
 public class ChromeFilter implements CapabilitiesFilter {
   @Override
   public Map apply(Map unmodifiedCaps) {
     Map caps = unmodifiedCaps.entrySet().parallelStream()
       .filter(
         entry ->
-          (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && BrowserType.CHROME.equals(entry.getValue())) ||
+          (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && CHROME.is(String.valueOf(entry.getValue()))) ||
           entry.getKey().startsWith("goog:") ||
           "chromeOptions".equals(entry.getKey()) ||
           "loggingPrefs".equals(entry.getKey()))
diff --git a/java/src/org/openqa/selenium/remote/session/EdgeFilter.java b/java/src/org/openqa/selenium/remote/session/EdgeFilter.java
index 612de06d7724c..0dab13fdb0b86 100644
--- a/java/src/org/openqa/selenium/remote/session/EdgeFilter.java
+++ b/java/src/org/openqa/selenium/remote/session/EdgeFilter.java
@@ -18,20 +18,20 @@
 package org.openqa.selenium.remote.session;
 
 import com.google.common.collect.ImmutableMap;
-
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.CapabilityType;
 
 import java.util.Map;
 import java.util.Objects;
 
+import static org.openqa.selenium.remote.Browser.EDGE;
+
 public class EdgeFilter implements CapabilitiesFilter {
 
   @Override
   public Map apply(Map unmodifiedCaps) {
     ImmutableMap caps = unmodifiedCaps.entrySet().parallelStream()
       .filter(
-        entry -> (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && BrowserType.EDGE.equals(entry.getValue())) ||
+        entry -> (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && EDGE.is(String.valueOf(entry.getValue()))) ||
                  entry.getKey().startsWith("ms:"))
       .distinct()
       .filter(entry -> Objects.nonNull(entry.getValue()))
diff --git a/java/src/org/openqa/selenium/remote/session/FirefoxFilter.java b/java/src/org/openqa/selenium/remote/session/FirefoxFilter.java
index bd26761e60c9a..9b0fe3be7e8da 100644
--- a/java/src/org/openqa/selenium/remote/session/FirefoxFilter.java
+++ b/java/src/org/openqa/selenium/remote/session/FirefoxFilter.java
@@ -17,7 +17,6 @@
 
 package org.openqa.selenium.remote.session;
 
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.CapabilityType;
 
 import java.util.Map;
@@ -25,6 +24,8 @@
 import java.util.TreeMap;
 import java.util.stream.Collectors;
 
+import static org.openqa.selenium.remote.Browser.FIREFOX;
+
 public class FirefoxFilter implements CapabilitiesFilter {
   // Note: we don't take a dependency on the FirefoxDriver jar as it might not be on the classpath
 
@@ -32,7 +33,7 @@ public class FirefoxFilter implements CapabilitiesFilter {
   public Map apply(Map unmodifiedCaps) {
     Map caps = unmodifiedCaps.entrySet().parallelStream()
       .filter(entry ->
-                (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && BrowserType.FIREFOX.equals(entry.getValue())) ||
+                (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && FIREFOX.is(String.valueOf(entry.getValue()))) ||
                 entry.getKey().startsWith("firefox_") ||
                 entry.getKey().startsWith("moz:"))
       .filter(entry -> Objects.nonNull(entry.getValue()))
diff --git a/java/src/org/openqa/selenium/remote/session/InternetExplorerFilter.java b/java/src/org/openqa/selenium/remote/session/InternetExplorerFilter.java
index 521bb8ecd5d7e..bcdfb5be39fef 100644
--- a/java/src/org/openqa/selenium/remote/session/InternetExplorerFilter.java
+++ b/java/src/org/openqa/selenium/remote/session/InternetExplorerFilter.java
@@ -18,19 +18,19 @@
 package org.openqa.selenium.remote.session;
 
 import com.google.common.collect.ImmutableMap;
-
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.CapabilityType;
 
 import java.util.Map;
 import java.util.Objects;
 
+import static org.openqa.selenium.remote.Browser.IE;
+
 public class InternetExplorerFilter implements CapabilitiesFilter {
   @Override
   public Map apply(Map unmodifiedCaps) {
     ImmutableMap caps = unmodifiedCaps.entrySet().parallelStream()
       .filter(entry ->
-                (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && BrowserType.IE.equals(entry.getValue())) ||
+                (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && IE.is(String.valueOf(entry.getValue()))) ||
                 "browserAttachTimeout".equals(entry.getKey()) ||
                 "enableElementCacheCleanup".equals(entry.getKey()) ||
                 "enablePersistentHover".equals(entry.getKey()) ||
diff --git a/java/src/org/openqa/selenium/remote/session/OperaFilter.java b/java/src/org/openqa/selenium/remote/session/OperaFilter.java
index 3980c4b57ba1f..533e8d2249842 100644
--- a/java/src/org/openqa/selenium/remote/session/OperaFilter.java
+++ b/java/src/org/openqa/selenium/remote/session/OperaFilter.java
@@ -18,20 +18,19 @@
 package org.openqa.selenium.remote.session;
 
 import com.google.common.collect.ImmutableMap;
-
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.CapabilityType;
 
 import java.util.Map;
 import java.util.Objects;
 
+import static org.openqa.selenium.remote.Browser.OPERA;
+
 public class OperaFilter implements CapabilitiesFilter {
   @Override
   public Map apply(Map unmodifiedCaps) {
     ImmutableMap caps = unmodifiedCaps.entrySet().parallelStream()
       .filter(entry ->
-                (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && BrowserType.OPERA.equals(entry.getValue())) ||
-                (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && BrowserType.OPERA_BLINK.equals(entry.getValue())) ||
+                (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && OPERA.is(String.valueOf(entry.getValue()))) ||
                 "operaOptions".equals(entry.getKey()))
       .distinct()
       .filter(entry -> Objects.nonNull(entry.getValue()))
diff --git a/java/src/org/openqa/selenium/remote/session/SafariFilter.java b/java/src/org/openqa/selenium/remote/session/SafariFilter.java
index fb98c20be9788..b7fe3ff57c36b 100644
--- a/java/src/org/openqa/selenium/remote/session/SafariFilter.java
+++ b/java/src/org/openqa/selenium/remote/session/SafariFilter.java
@@ -18,19 +18,19 @@
 package org.openqa.selenium.remote.session;
 
 import com.google.common.collect.ImmutableMap;
-
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.CapabilityType;
 
 import java.util.Map;
 import java.util.Objects;
 
+import static org.openqa.selenium.remote.Browser.SAFARI;
+
 public class SafariFilter implements CapabilitiesFilter {
   @Override
   public Map apply(Map unmodifiedCaps) {
     ImmutableMap caps = unmodifiedCaps.entrySet().parallelStream()
       .filter(entry ->
-                (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && BrowserType.SAFARI.equals(entry.getValue())) ||
+                (CapabilityType.BROWSER_NAME.equals(entry.getKey()) && SAFARI.is(String.valueOf(entry.getValue()))) ||
                 "safari.options".equals(entry.getKey()))
       .distinct()
       .filter(entry -> Objects.nonNull(entry.getValue()))
diff --git a/java/src/org/openqa/selenium/safari/SafariDriverInfo.java b/java/src/org/openqa/selenium/safari/SafariDriverInfo.java
index eff7084e3ffd9..42d93a4936152 100644
--- a/java/src/org/openqa/selenium/safari/SafariDriverInfo.java
+++ b/java/src/org/openqa/selenium/safari/SafariDriverInfo.java
@@ -18,17 +18,16 @@
 package org.openqa.selenium.safari;
 
 import com.google.auto.service.AutoService;
-
 import org.openqa.selenium.Capabilities;
 import org.openqa.selenium.ImmutableCapabilities;
 import org.openqa.selenium.SessionNotCreatedException;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebDriverException;
 import org.openqa.selenium.WebDriverInfo;
-import org.openqa.selenium.remote.BrowserType;
 
 import java.util.Optional;
 
+import static org.openqa.selenium.remote.Browser.SAFARI;
 import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;
 
 @AutoService(WebDriverInfo.class)
@@ -41,12 +40,12 @@ public String getDisplayName() {
 
   @Override
   public Capabilities getCanonicalCapabilities() {
-    return new ImmutableCapabilities(BROWSER_NAME, BrowserType.SAFARI);
+    return new ImmutableCapabilities(BROWSER_NAME, SAFARI.browserName());
   }
 
   @Override
   public boolean isSupporting(Capabilities capabilities) {
-    if (BrowserType.SAFARI.equalsIgnoreCase(capabilities.getBrowserName())) {
+    if (SAFARI.is(capabilities)) {
       return true;
     }
 
diff --git a/java/src/org/openqa/selenium/safari/SafariDriverService.java b/java/src/org/openqa/selenium/safari/SafariDriverService.java
index b16b07bb9b185..1812cc4788246 100644
--- a/java/src/org/openqa/selenium/safari/SafariDriverService.java
+++ b/java/src/org/openqa/selenium/safari/SafariDriverService.java
@@ -17,16 +17,11 @@
 
 package org.openqa.selenium.safari;
 
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.openqa.selenium.Platform.MAC;
-
 import com.google.auto.service.AutoService;
-
 import org.openqa.selenium.Capabilities;
 import org.openqa.selenium.Platform;
 import org.openqa.selenium.WebDriverException;
 import org.openqa.selenium.net.PortProber;
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.service.DriverService;
 
 import java.io.File;
@@ -36,6 +31,10 @@
 import java.util.List;
 import java.util.Map;
 
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.openqa.selenium.Platform.MAC;
+import static org.openqa.selenium.remote.Browser.SAFARI;
+
 public class SafariDriverService extends DriverService {
 
   /**
@@ -98,7 +97,7 @@ public static class Builder extends DriverService.Builder<
     public int score(Capabilities capabilities) {
       int score = 0;
 
-      if (BrowserType.SAFARI.equals(capabilities.getBrowserName())) {
+      if (SAFARI.is(capabilities)) {
         score++;
       } else if (SafariOptions.SAFARI_TECH_PREVIEW.equals(capabilities.getBrowserName())) {
         score++;
diff --git a/java/src/org/openqa/selenium/safari/SafariOptions.java b/java/src/org/openqa/selenium/safari/SafariOptions.java
index 78ba4bbbf280c..1fc32df1ea326 100644
--- a/java/src/org/openqa/selenium/safari/SafariOptions.java
+++ b/java/src/org/openqa/selenium/safari/SafariOptions.java
@@ -17,13 +17,13 @@
 
 package org.openqa.selenium.safari;
 
+import static org.openqa.selenium.remote.Browser.SAFARI;
 import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;
 
 import org.openqa.selenium.Capabilities;
 import org.openqa.selenium.WebDriverException;
 import org.openqa.selenium.internal.Require;
 import org.openqa.selenium.remote.AbstractDriverOptions;
-import org.openqa.selenium.remote.BrowserType;
 
 import java.util.Collections;
 import java.util.Set;
@@ -51,7 +51,7 @@ public class SafariOptions extends AbstractDriverOptions {
 
   public SafariOptions() {
     setUseTechnologyPreview(false);
-    setCapability(BROWSER_NAME, BrowserType.SAFARI);
+    setCapability(BROWSER_NAME, SAFARI.browserName());
   }
 
   public SafariOptions(Capabilities source) {
diff --git a/java/test/org/openqa/selenium/edge/EdgeDriverInfoTest.java b/java/test/org/openqa/selenium/edge/EdgeDriverInfoTest.java
index 66491e48d9459..a7e32e8bd46ac 100644
--- a/java/test/org/openqa/selenium/edge/EdgeDriverInfoTest.java
+++ b/java/test/org/openqa/selenium/edge/EdgeDriverInfoTest.java
@@ -17,52 +17,55 @@
 
 package org.openqa.selenium.edge;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 import org.assertj.core.api.Condition;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.openqa.selenium.Capabilities;
 import org.openqa.selenium.ImmutableCapabilities;
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.CapabilityType;
 import org.openqa.selenium.testing.UnitTests;
 
 import java.util.Collections;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.openqa.selenium.remote.Browser.EDGE;
+import static org.openqa.selenium.remote.Browser.FIREFOX;
+
 @Category(UnitTests.class)
 public class EdgeDriverInfoTest {
 
   @Test
   public void canonicalCapabilitiesContainProperBrowserName() {
     Capabilities caps = new EdgeDriverInfo().getCanonicalCapabilities();
-    assertThat(caps.getBrowserName()).isEqualTo(BrowserType.EDGE);
+    assertThat(caps.getBrowserName()).isEqualTo(EDGE.browserName());
   }
 
   @Test
   public void isSupportingCapabilitiesWithProperBrowserNameOnly() {
     assertThat(new EdgeDriverInfo()).is(supporting(
-        new ImmutableCapabilities(CapabilityType.BROWSER_NAME, BrowserType.EDGE)));
+        new ImmutableCapabilities(CapabilityType.BROWSER_NAME, EDGE.browserName())));
   }
 
   @Test
   public void isNotSupportingEdgeHtml() {
     assertThat(new EdgeDriverInfo()).isNot(supporting(
-        new ImmutableCapabilities(CapabilityType.BROWSER_NAME, BrowserType.EDGE,
-                                  EdgeOptions.USE_CHROMIUM, false)));
+        new ImmutableCapabilities(
+          CapabilityType.BROWSER_NAME, EDGE.browserName(),
+          EdgeOptions.USE_CHROMIUM, false)));
   }
 
   @Test
   public void isSupportingEdgeWithExplicitlySetChromiumFlag() {
     assertThat(new EdgeDriverInfo()).is(supporting(
-        new ImmutableCapabilities(CapabilityType.BROWSER_NAME, BrowserType.EDGE,
-                                  EdgeOptions.USE_CHROMIUM, true)));
+        new ImmutableCapabilities(
+          CapabilityType.BROWSER_NAME, EDGE.browserName(),
+          EdgeOptions.USE_CHROMIUM, true)));
   }
 
   @Test
   public void isNotSupportingFirefox() {
     assertThat(new EdgeDriverInfo()).isNot(supporting(
-        new ImmutableCapabilities(CapabilityType.BROWSER_NAME, BrowserType.FIREFOX)));
+        new ImmutableCapabilities(CapabilityType.BROWSER_NAME, FIREFOX.browserName())));
   }
 
   @Test
@@ -86,4 +89,4 @@ public void canRejectEdgeHtmlByVendorSpecificCapability() {
   private Condition supporting(Capabilities capabilities) {
     return new Condition<>(info -> info.isSupporting(capabilities), "supporting " + capabilities);
   }
-}
\ No newline at end of file
+}
diff --git a/java/test/org/openqa/selenium/edge/EdgeOptionsTest.java b/java/test/org/openqa/selenium/edge/EdgeOptionsTest.java
index 66f31ab37a8cf..e63287750800e 100644
--- a/java/test/org/openqa/selenium/edge/EdgeOptionsTest.java
+++ b/java/test/org/openqa/selenium/edge/EdgeOptionsTest.java
@@ -17,17 +17,11 @@
 
 package org.openqa.selenium.edge;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
-import static org.assertj.core.api.InstanceOfAssertFactories.MAP;
-
 import com.google.common.io.Files;
-
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.openqa.selenium.ImmutableCapabilities;
 import org.openqa.selenium.PageLoadStrategy;
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.CapabilityType;
 import org.openqa.selenium.testing.UnitTests;
 
@@ -42,6 +36,11 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
+import static org.assertj.core.api.InstanceOfAssertFactories.MAP;
+import static org.openqa.selenium.remote.Browser.EDGE;
+
 @Category(UnitTests.class)
 public class EdgeOptionsTest {
 
@@ -92,7 +91,7 @@ public void canMergeWithoutChangingOriginalObject() {
 
   private void checkCommonStructure(EdgeOptions options) {
     assertThat(options.asMap())
-        .containsEntry(CapabilityType.BROWSER_NAME, BrowserType.EDGE)
+        .containsEntry(CapabilityType.BROWSER_NAME, EDGE.browserName())
         .extracting(EdgeOptions.CAPABILITY).asInstanceOf(MAP)
         .containsOnlyKeys("args", "extensions");
   }
diff --git a/java/test/org/openqa/selenium/remote/RemoteWebDriverBuilderTest.java b/java/test/org/openqa/selenium/remote/RemoteWebDriverBuilderTest.java
index 13d3ffc8a69e5..8471d3d8a4e87 100644
--- a/java/test/org/openqa/selenium/remote/RemoteWebDriverBuilderTest.java
+++ b/java/test/org/openqa/selenium/remote/RemoteWebDriverBuilderTest.java
@@ -52,8 +52,8 @@
 import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.openqa.selenium.json.Json.JSON_UTF_8;
 import static org.openqa.selenium.json.Json.MAP_TYPE;
-import static org.openqa.selenium.remote.BrowserType.CHROME;
-import static org.openqa.selenium.remote.BrowserType.FIREFOX;
+import static org.openqa.selenium.remote.Browser.CHROME;
+import static org.openqa.selenium.remote.Browser.FIREFOX;
 
 import com.google.common.collect.ImmutableMap;
 
@@ -88,7 +88,7 @@ public void mustSpecifyAtLeastOneSetOfOptions() {
 
     assertThat(caps).hasSize(1);
     List caps0 = caps.get(0);
-    assertThat(caps0.get(0).getBrowserName()).isEqualTo(FIREFOX);
+    assertThat(caps0.get(0).getBrowserName()).isEqualTo(FIREFOX.browserName());
   }
 
   @Test
@@ -259,7 +259,7 @@ public void oneOfWillClearOutTheCurrentlySetCapabilities() {
       .address("http://localhost:34576")
       .connectingWith(config -> req -> {
         List caps = listCapabilities(req);
-        allOk.set(caps.size() == 1 && caps.get(0).getBrowserName().equals(CHROME));
+        allOk.set(caps.size() == 1 && caps.get(0).getBrowserName().equals(CHROME.browserName()));
         return CANNED_SESSION_RESPONSE;
       })
       .build();
diff --git a/java/test/org/openqa/selenium/safari/SafariOptionsTest.java b/java/test/org/openqa/selenium/safari/SafariOptionsTest.java
index cf8153441b0f1..e706b19d093a4 100644
--- a/java/test/org/openqa/selenium/safari/SafariOptionsTest.java
+++ b/java/test/org/openqa/selenium/safari/SafariOptionsTest.java
@@ -17,15 +17,10 @@
 
 package org.openqa.selenium.safari;
 
-import static java.util.stream.Collectors.toSet;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
-
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.openqa.selenium.ImmutableCapabilities;
 import org.openqa.selenium.remote.AcceptedW3CCapabilityKeys;
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.remote.CapabilityType;
 import org.openqa.selenium.testing.UnitTests;
 
@@ -33,6 +28,11 @@
 import java.util.Set;
 import java.util.function.Predicate;
 
+import static java.util.stream.Collectors.toSet;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.openqa.selenium.remote.Browser.SAFARI;
+
 @Category(UnitTests.class)
 public class SafariOptionsTest {
 
@@ -57,7 +57,7 @@ public void canConstructFromCapabilities() {
     assertThat(options.getUseTechnologyPreview()).isTrue();
 
     options = new SafariOptions(
-      new ImmutableCapabilities(CapabilityType.BROWSER_NAME, BrowserType.SAFARI));
+      new ImmutableCapabilities(CapabilityType.BROWSER_NAME, SAFARI.browserName()));
     assertThat(options.getUseTechnologyPreview()).isFalse();
   }
 
@@ -76,13 +76,13 @@ public void canSetAutomaticProfiling() {
   @Test
   public void settingTechnologyPreviewModeAlsoChangesBrowserName() {
     SafariOptions options = new SafariOptions();
-    assertThat(options.getBrowserName()).isEqualTo(BrowserType.SAFARI);
+    assertThat(options.getBrowserName()).isEqualTo(SAFARI.browserName());
 
     options.setUseTechnologyPreview(true);
     assertThat(options.getBrowserName()).isEqualTo(SafariOptions.SAFARI_TECH_PREVIEW);
 
     options.setUseTechnologyPreview(false);
-    assertThat(options.getBrowserName()).isEqualTo(BrowserType.SAFARI);
+    assertThat(options.getBrowserName()).isEqualTo(SAFARI.browserName());
   }
 
   @Test
diff --git a/java/test/org/openqa/selenium/testing/drivers/Browser.java b/java/test/org/openqa/selenium/testing/drivers/Browser.java
index 8d75be16d4497..b117a5deed4f0 100644
--- a/java/test/org/openqa/selenium/testing/drivers/Browser.java
+++ b/java/test/org/openqa/selenium/testing/drivers/Browser.java
@@ -30,7 +30,6 @@
 import org.openqa.selenium.ie.InternetExplorerOptions;
 import org.openqa.selenium.opera.OperaDriverInfo;
 import org.openqa.selenium.opera.OperaOptions;
-import org.openqa.selenium.remote.BrowserType;
 import org.openqa.selenium.safari.SafariDriverInfo;
 import org.openqa.selenium.safari.SafariOptions;
 
@@ -96,7 +95,8 @@ public Capabilities getCapabilities() {
       return options;
     }
   },
-  HTMLUNIT(new ImmutableCapabilities(BROWSER_NAME, BrowserType.HTMLUNIT), "HtmlUnit", false),
+  HTMLUNIT(
+    new ImmutableCapabilities(BROWSER_NAME, org.openqa.selenium.remote.Browser.HTMLUNIT.browserName()), "HtmlUnit", false),
   LEGACY_FIREFOX_XPI(new FirefoxOptions().setLegacy(true), new XpiDriverInfo().getDisplayName(), false),
   IE(new InternetExplorerOptions(), new InternetExplorerDriverInfo().getDisplayName(), false) {
     @Override
diff --git a/java/test/org/openqa/selenium/testing/drivers/DefaultDriverSupplier.java b/java/test/org/openqa/selenium/testing/drivers/DefaultDriverSupplier.java
index cd029659a6e27..4fe966752ea79 100644
--- a/java/test/org/openqa/selenium/testing/drivers/DefaultDriverSupplier.java
+++ b/java/test/org/openqa/selenium/testing/drivers/DefaultDriverSupplier.java
@@ -21,7 +21,6 @@
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebDriverInfo;
 import org.openqa.selenium.htmlunit.HtmlUnitDriver;
-import org.openqa.selenium.remote.BrowserType;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -42,7 +41,7 @@ public WebDriver get() {
     Function driverConstructor;
 
     if (capabilities != null) {
-      if (capabilities.getBrowserName().equals(BrowserType.HTMLUNIT)) {
+      if (org.openqa.selenium.remote.Browser.HTMLUNIT.is(capabilities)) {
         return new HtmlUnitDriver();
       }
 
diff --git a/java/test/org/openqa/selenium/testing/drivers/TestInternetExplorerSupplier.java b/java/test/org/openqa/selenium/testing/drivers/TestInternetExplorerSupplier.java
index 2dc57302ce680..e3eead39a9a7d 100644
--- a/java/test/org/openqa/selenium/testing/drivers/TestInternetExplorerSupplier.java
+++ b/java/test/org/openqa/selenium/testing/drivers/TestInternetExplorerSupplier.java
@@ -19,7 +19,6 @@
 
 import org.openqa.selenium.Capabilities;
 import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.remote.BrowserType;
 
 import java.util.function.Supplier;
 
@@ -36,7 +35,7 @@ public WebDriver get() {
       return null;
     }
 
-    if (!BrowserType.IE.equals(caps.getBrowserName())) {
+    if (!org.openqa.selenium.remote.Browser.IE.is(caps)) {
       return null;
     }