|
18 | 18 | package org.openqa.selenium.remote.server;
|
19 | 19 |
|
20 | 20 | import static com.google.common.base.Preconditions.checkState;
|
| 21 | +import static org.openqa.selenium.remote.BrowserType.CHROME; |
| 22 | +import static org.openqa.selenium.remote.BrowserType.EDGE; |
| 23 | +import static org.openqa.selenium.remote.BrowserType.FIREFOX; |
| 24 | +import static org.openqa.selenium.remote.BrowserType.HTMLUNIT; |
| 25 | +import static org.openqa.selenium.remote.BrowserType.IE; |
| 26 | +import static org.openqa.selenium.remote.BrowserType.OPERA; |
| 27 | +import static org.openqa.selenium.remote.BrowserType.OPERA_BLINK; |
| 28 | +import static org.openqa.selenium.remote.BrowserType.PHANTOMJS; |
| 29 | +import static org.openqa.selenium.remote.BrowserType.SAFARI; |
| 30 | +import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME; |
21 | 31 | import static org.openqa.selenium.remote.server.DefaultDriverProvider.createProvider;
|
22 | 32 |
|
23 | 33 | import com.google.common.annotations.VisibleForTesting;
|
24 | 34 | import com.google.common.collect.ImmutableList;
|
| 35 | +import com.google.common.collect.ImmutableMap; |
25 | 36 |
|
26 | 37 | import org.openqa.selenium.Capabilities;
|
| 38 | +import org.openqa.selenium.ImmutableCapabilities; |
27 | 39 | import org.openqa.selenium.Platform;
|
28 | 40 | import org.openqa.selenium.WebDriver;
|
29 | 41 | import org.openqa.selenium.WebDriverException;
|
30 |
| -import org.openqa.selenium.remote.DesiredCapabilities; |
31 | 42 |
|
32 | 43 | import java.util.List;
|
33 | 44 | import java.util.Map;
|
34 | 45 | import java.util.Objects;
|
35 | 46 | import java.util.ServiceLoader;
|
36 | 47 | import java.util.concurrent.ConcurrentHashMap;
|
37 | 48 | import java.util.logging.Logger;
|
38 |
| -import java.util.stream.Stream; |
39 | 49 |
|
40 | 50 | public class DefaultDriverFactory implements DriverFactory {
|
41 | 51 |
|
42 | 52 | private static final Logger LOG = Logger.getLogger(DefaultDriverFactory.class.getName());
|
43 | 53 |
|
44 | 54 | private static final List<DriverProvider> DEFAULT_DRIVER_PROVIDERS =
|
45 |
| - Stream.of( |
46 |
| - createProvider(DesiredCapabilities.firefox(), "org.openqa.selenium.firefox.FirefoxDriver"), |
47 |
| - createProvider(DesiredCapabilities.chrome(), "org.openqa.selenium.chrome.ChromeDriver"), |
48 |
| - createProvider(DesiredCapabilities.internetExplorer(), "org.openqa.selenium.ie.InternetExplorerDriver"), |
49 |
| - createProvider(DesiredCapabilities.edge(), "org.openqa.selenium.edge.EdgeDriver"), |
50 |
| - createProvider(DesiredCapabilities.opera(), "com.opera.core.systems.OperaDriver"), |
51 |
| - createProvider(DesiredCapabilities.operaBlink(), "org.openqa.selenium.opera.OperaDriver"), |
52 |
| - createProvider(DesiredCapabilities.safari(), "org.openqa.selenium.safari.SafariDriver"), |
53 |
| - createProvider(DesiredCapabilities.phantomjs(), "org.openqa.selenium.phantomjs.PhantomJSDriver"), |
54 |
| - createProvider(DesiredCapabilities.htmlUnit(), "org.openqa.selenium.htmlunit.HtmlUnitDriver")) |
| 55 | + new ImmutableMap.Builder<String, String>() |
| 56 | + .put(FIREFOX, "org.openqa.selenium.firefox.FirefoxDriver") |
| 57 | + .put(CHROME, "org.openqa.selenium.chrome.ChromeDriver") |
| 58 | + .put(IE, "org.openqa.selenium.ie.InternetExplorerDriver") |
| 59 | + .put(EDGE, "org.openqa.selenium.edge.EdgeDriver") |
| 60 | + .put(OPERA, "com.opera.core.systems.OperaDriver") |
| 61 | + .put(OPERA_BLINK, "org.openqa.selenium.opera.OperaDriver") |
| 62 | + .put(SAFARI, "org.openqa.selenium.safari.SafariDriver") |
| 63 | + .put(PHANTOMJS, "org.openqa.selenium.phantomjs.PhantomJSDriver") |
| 64 | + .put(HTMLUNIT, "org.openqa.selenium.htmlunit.HtmlUnitDriver") |
| 65 | + .build().entrySet().stream() |
| 66 | + .map(e -> createProvider(new ImmutableCapabilities(BROWSER_NAME, e.getKey()), e.getValue())) |
55 | 67 | .filter(Objects::nonNull)
|
56 | 68 | .collect(ImmutableList.toImmutableList());
|
57 | 69 |
|
|
0 commit comments