Capabilities getBrowserBinaryCapabilities(Config config, Browser browser) { log.info("Using browser binary: " + config.browserBinary()); if (browser.isChrome()) { ChromeOptions options = new ChromeOptions(); options.setBinary(config.browserBinary()); return options; } else if (browser.isFirefox()) { FirefoxOptions options = new FirefoxOptions(); options.setBinary(config.browserBinary()); return options; } else { log.warning("Changing browser binary on remote server is only supported for Chrome/Firefox, setting will be ignored."); } return new DesiredCapabilities(); }
FirefoxOptions createFirefoxOptions(Config config, Proxy proxy) { FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setHeadless(config.headless()); if (!config.browserBinary().isEmpty()) { log.info("Using browser binary: " + config.browserBinary()); firefoxOptions.setBinary(config.browserBinary()); } firefoxOptions.addPreference("network.automatic-ntlm-auth.trusted-uris", "http://,https://"); firefoxOptions.addPreference("network.automatic-ntlm-auth.allow-non-fqdn", true); firefoxOptions.addPreference("network.negotiate-auth.delegation-uris", "http://,https://"); firefoxOptions.addPreference("network.negotiate-auth.trusted-uris", "http://,https://"); firefoxOptions.addPreference("network.http.phishy-userpass-length", 255); firefoxOptions.addPreference("security.csp.enable", false); firefoxOptions.addPreference("network.proxy.no_proxies_on", ""); firefoxOptions.merge(createCommonCapabilities(config, proxy)); firefoxOptions = transferFirefoxProfileFromSystemProperties(firefoxOptions); return firefoxOptions; }
/** * Sets specific {@link FirefoxBinary} to be used in the {@link FirefoxDriver}. * * @param firefoxBinary Binary to be used. * @return A self reference, allowing further configuration. * @since 0.18.0 */ public FirefoxDriverBuilder withBinary(FirefoxBinary firefoxBinary) { getInitializedFirefoxOptions().setBinary(firefoxBinary); return this; }
/** * Sets specific {@link FirefoxBinary} to be used in the {@link FirefoxDriver}. * * @param firefoxBinary Binary to be used. * @return A self reference, allowing further configuration. * @since 0.18.0 */ public FirefoxDriverBuilder withBinary(FirefoxBinary firefoxBinary) { getInitializedFirefoxOptions().setBinary(firefoxBinary); return this; }
@Override public WebDriver create(Capabilities capabilities, Properties properties) { final File firefoxPath = new File(properties.getProperty(ConfigKeys.WEBDRIVER_FIREFOX_BIN)); FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath); firefoxBinary.setEnvironmentProperty("DISPLAY", properties.getProperty(ConfigKeys.WEBDRIVER_XVFB_ID)); FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities).setBinary(firefoxBinary); return new FirefoxDriver(firefoxOptions); } };
@Override public WebDriver create(Capabilities capabilities, Properties properties) { final File firefoxPath = new File(properties.getProperty(ConfigKeys.WEBDRIVER_FIREFOX_BIN)); FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath); firefoxBinary.setEnvironmentProperty("DISPLAY", properties.getProperty(ConfigKeys.WEBDRIVER_XVFB_ID)); FirefoxOptions firefoxOptions = new FirefoxOptions(capabilities).setBinary(firefoxBinary); return new FirefoxDriver(firefoxOptions); } };
public FirefoxOptions() { // Read system properties and use those if they are set, allowing users to override them later // should they want to. String binary = System.getProperty(FirefoxDriver.SystemProperty.BROWSER_BINARY); if (binary != null) { setBinary(binary); } String profileName = System.getProperty(FirefoxDriver.SystemProperty.BROWSER_PROFILE); if (profileName != null) { FirefoxProfile profile = new ProfilesIni().getProfile(profileName); if (profile == null) { throw new WebDriverException(String.format( "Firefox profile '%s' named in system property '%s' not found", profileName, FirefoxDriver.SystemProperty.BROWSER_PROFILE)); } setProfile(profile); } String forceMarionette = System.getProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE); if (forceMarionette != null) { setLegacy(!Boolean.getBoolean(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE)); } setCapability(CapabilityType.BROWSER_NAME, BrowserType.FIREFOX); setAcceptInsecureCerts(true); }
@Override protected void updateOptionsWithSelectedBrowserInfo(MutableCapabilities options) { if (BrowserInfo.useLegacyFirefoxVersion(selectedBrowserInfo.getVersion())) { options.setCapability(FirefoxDriver.MARIONETTE, false); } else { options.setCapability(FirefoxDriver.MARIONETTE, true); } ((FirefoxOptions)options).setBinary(selectedBrowserInfo.getPath()); }
if (that.containsKey("binary")) { setBinary((String) that.get("binary")); } if (that.containsKey("log")) { Map<?, ?> logStruct = (Map<?, ?>) that.get("log");
options.setBinary(new FirefoxBinary(new File(firefoxPath)));
firefoxOptions.setBinary(binary.value());
@Override public WebDriver newInstance(DriverOptions driverOptions) { GeckoDriverService service = setupBuilder(new GeckoDriverService.Builder(), driverOptions, GECKODRIVER).build(); FirefoxOptions firefoxOptions = newFirefoxOptions(driverOptions); String firefoxBin = getFirefoxBinary(driverOptions); if (firefoxBin != null) firefoxOptions.setBinary(firefoxBin); if (driverOptions.has(CLI_ARGS)) firefoxOptions.addArguments(driverOptions.getCliArgs()); FirefoxProfile profile = getFirefoxProfile(driverOptions); if (profile != null) firefoxOptions.setProfile(profile); firefoxOptions.merge(driverOptions.getCapabilities()); FirefoxDriver driver = new FirefoxDriver(service, firefoxOptions); setInitialWindowSize(driver, driverOptions); return driver; }