[java] Avoid using ServiceLoader while creating FirefoxDriver instance
Fixes and
import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
-import java.util.ServiceLoader;
-import java.util.stream.StreamSupport;
/**
* An implementation of the {#link WebDriver} interface that drives Firefox.
@@ -103,8 +101,9 @@ public FirefoxDriver(FirefoxDriverService service, Capabilities desiredCapabilit
Require.nonNull("Driver service", service),
new FirefoxOptions(desiredCapabilities));
}
+
public FirefoxDriver(FirefoxOptions options) {
- this(toExecutor(options), options);
+ this(new FirefoxDriverCommandExecutor(GeckoDriverService.createDefaultService()), options);
}
public FirefoxDriver(FirefoxDriverService service) {
@@ -141,18 +140,6 @@ public static RemoteWebDriverBuilder builder() {
return RemoteWebDriver.builder().oneOf(new FirefoxOptions());
}
- private static FirefoxDriverCommandExecutor toExecutor(FirefoxOptions options) {
- Require.nonNull("Options to construct executor from", options);
-
- FirefoxDriverService.Builder<?, ?> builder =
- StreamSupport.stream(ServiceLoader.load(DriverService.Builder.class).spliterator(), false)
- .filter(b -> b instanceof FirefoxDriverService.Builder)
- .map(FirefoxDriverService.Builder.class::cast)
- .findFirst().orElseThrow(WebDriverException::new);
-
- return new FirefoxDriverCommandExecutor(builder.withOptions(options).build());
- }
-
/**
* Check capabilities and proxy if it is set
*/
