void amendOptions(FirefoxOptions options) { options.addArguments(extraOptions); }
public FirefoxOptions addArguments(String... arguments) { addArguments(ImmutableList.copyOf(arguments)); return this; }
@Override protected MutableCapabilities getDriverOptions() { FirefoxOptions options = new FirefoxOptions(); if (webDriverConfig.isHeadlessBrowser()) { logger.info("setting firefox in headless mode. Supported for firefox version >= 56"); options.addArguments("-headless"); options.addArguments("--window-size=1280,1024"); options.addArguments("--width=1280"); options.addArguments("--height=1024"); } FirefoxProfile profile = getFirefoxProfile(webDriverConfig); configProfile(profile, webDriverConfig); options.setCapability(FirefoxDriver.PROFILE, profile); options.setLogLevel(FirefoxDriverLogLevel.ERROR); if (webDriverConfig.isDevMode()) { options.setLogLevel(FirefoxDriverLogLevel.TRACE); } // handle https://bugzilla.mozilla.org/show_bug.cgi?id=1429338#c4 and https://github.com/mozilla/geckodriver/issues/789 options.setCapability("moz:useNonSpecCompliantPointerOrigin", true); return options; }
FirefoxOptions that = (FirefoxOptions) raw; addArguments(that.args); that.booleanPrefs.forEach(this::addPreference); that.intPrefs.forEach(this::addPreference); Object value = that.get("args"); if (value instanceof String) { addArguments((String) that.get("args")); } else if (value instanceof List<?>) { addArguments((List<String>) that.get("args")); } else { addArguments(that.get("args").toString());
/** * Задает options для запуска Firefox драйвера * options можно передавать, как системную переменную, например -Doptions=--load-extension=my-custom-extension * @return FirefoxOptions */ private FirefoxOptions getFirefoxDriverOptions(DesiredCapabilities capabilities) { log.info("---------------Firefox Driver---------------------"); FirefoxOptions firefoxOptions = !options[0].equals("") ? new FirefoxOptions().addArguments(options) : new FirefoxOptions(); capabilities.setVersion(loadSystemPropertyOrDefault(CapabilityType.BROWSER_VERSION, VERSION_LATEST)); firefoxOptions.setHeadless(getHeadless()); firefoxOptions.merge(capabilities); return firefoxOptions; }
private WebDriver createWebDriver(DriverManagerType driverManagerType) throws IllegalArgumentException, WebDriverManagerException { switch (driverManagerType) { case CHROME: ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setHeadless(true); chromeOptions.addArguments(jooUnitWebDriverBrowserArguments); getLog().info("Starting Chrome with " + jooUnitWebDriverBrowserArguments.size() + " arguments: " + String.join(" ", jooUnitWebDriverBrowserArguments)); return new ChromeDriver(chromeOptions); case FIREFOX: FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setHeadless(true); firefoxOptions.addArguments(jooUnitWebDriverBrowserArguments); getLog().info("Starting Firefox with " + jooUnitWebDriverBrowserArguments.size() + " arguments: " + String.join(" ", jooUnitWebDriverBrowserArguments)); return new FirefoxDriver(firefoxOptions); case EDGE: return new EdgeDriver(); // no headless mode and no arguments yet :-( case IEXPLORER: return new InternetExplorerDriver(); // no headless mode and no arguments yet :-( case OPERA: return new OperaDriver(); // no headless mode and no arguments yet :-( } throw new IllegalArgumentException(); }
options.addArguments("-headless", "-safe-mode");
@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; }
FirefoxOptions options = new FirefoxOptions(); options.setProfile(getFirefoxProfileWithDisabledAnimatedGifs()); options.addArguments(runStepConfig.getFirefoxParameters()); if (jobConfig.browser.isHeadless()) { options.setHeadless(true); options.addArguments("-width", width + "", "-height", jobConfig.windowHeight + "");
options.addArguments(format("user-data-dir=%s", drCustomProfileDir));
firefoxOptions.setProfile(firefoxProfile); if (browser.isHeadless()) { firefoxOptions.addArguments("-headless"); firefoxOptions.addArguments(flag);