private static CommandExecutor toExecutor(FirefoxOptions options) { Objects.requireNonNull(options, "No options to construct executor from"); DriverService.Builder<?, ?> builder; if (! Boolean.parseBoolean(System.getProperty(SystemProperty.DRIVER_USE_MARIONETTE, "true")) || options.isLegacy()) { FirefoxProfile profile = options.getProfile(); if (profile == null) { profile = new FirefoxProfile(); options.setCapability(FirefoxDriver.PROFILE, profile); } builder = XpiDriverService.builder() .withBinary(options.getBinary()) .withProfile(profile); } else { builder = new GeckoDriverService.Builder() .usingFirefoxBinary(options.getBinary()); } return new FirefoxDriverCommandExecutor(builder.build()); }