ChromeOptions createChromeOptions(Config config, Proxy proxy) { ChromeOptions options = new ChromeOptions(); options.setHeadless(config.headless()); if (!config.browserBinary().isEmpty()) { log.info("Using browser binary: " + config.browserBinary()); options.setBinary(config.browserBinary()); } options.merge(createCommonCapabilities(config, proxy)); options = transferChromeOptionsFromSystemProperties(options); log.config("Chrome options:" + options.toString()); return options; }
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(); }
private void updateChromeBinaryIfSpecified(ChromeOptions options) { String chromeBinary = environmentVariables.getProperty(ThucydidesSystemProperty.WEBDRIVER_CHROME_BINARY); if (StringUtils.isNotEmpty(chromeBinary)) { options.setBinary(chromeBinary); } }
System.setProperty("webdriver.chrome.driver","/<path to chrome driver>/chromedriver"); ChromeOptions options = new ChromeOptions(); options.setBinary(new File("/<path to chrome >/google-chrome")); driver = new ChromeDriver(options); try { //automated steps } finally { driver.quit(); }
@Override protected void updateOptionsWithSelectedBrowserInfo(MutableCapabilities options) { ((ChromeOptions)options).setBinary(selectedBrowserInfo.getPath()); }
ChromeOptions options = new ChromeOptions(); options.setBinary("/path/to/chrome/binary"); ChromeDriver driver = new ChromeDriver(options);
ChromeOptions options = new ChromeOptions(); options.setBinary("C:\\Selenium\\Browsers\\GoogleChromePortable\\GoogleChromePortable.exe"); System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\Browsers\\chromedriver.exe"); driver = new ChromeDriver(options);
ChromeOptions options = new ChromeOptions(); options.setBinary(new File("/path/to/chrome")); ChromeDriver driver = new ChromeDriver(options);
ChromeOptions options = new ChromeOptions(); options.setBinary("/path/to/other/chrome/binary");
ChromeOptions options = new ChromeOptions() options.setBinary(new File("/path/to/chrome")); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(ChromeOptions.CAPABILITY, options); ChromeDriver driver = new ChromeDriver(capabilities);
protected ChromeOptions getChromeOptions() { ChromeOptions options = new ChromeOptions(); if (isMac()) { // Try to use the chrome installed by homebrew cask File chromeInstalledByHomebrew = new File("/opt/homebrew-cask/Caskroom/google-chrome/latest/Google Chrome.app/Contents/MacOS/Google Chrome"); if (chromeInstalledByHomebrew.exists()) { options.setBinary(chromeInstalledByHomebrew); } } return options; }
protected ChromeOptions getChromeOptions() { ChromeOptions options = new ChromeOptions(); if (Configuration.isMac()) { File chromeInstalledByHomebrew = new File("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"); if (chromeInstalledByHomebrew.exists()) { options.setBinary(chromeInstalledByHomebrew); } } return options; }
ChromeOptions opt = new ChromeOptions(); opt.setBinary("E:\\some\\path\\chrome.exe"); opt.addArguments("--user-data-dir=C:\\Users\\Owner\\AppData\\Local\\Google\\Chrome\\User Data"); driver = new ChromeDriver(opt);
protected ChromeOptions addChromeOption(ChromeOptions chromeOptions, String key, Object value) { switch (key) { case OPTIONS_KEY_BINARY: chromeOptions.setBinary(value.toString()); break; case OPTIONS_KEY_ARGS: String[] arguments = (String[])value; chromeOptions.addArguments(arguments); break; default: getLogger().debug(GaleniumReportUtil.MARKER_ERROR, "cannot map option key: '" + key + "'"); break; } return chromeOptions; }
@Override public ChromeOptions produceOptions(Iterable<String> arguments) { ChromeOptions options = new ChromeOptions(); String binaryPath = getBinaryPathOverride(); if (binaryPath != null) { options.setBinary(binaryPath); } arguments = ImmutableList.copyOf(Iterables.concat(getAdditionalChromeArgs(), arguments)); LoggerFactory.getLogger(getClass()).debug("produced ChromeOptions with binary {} and args {}", binaryPath, arguments); options.addArguments(ImmutableList.copyOf(arguments)); return options; } }
@Override public ChromeOptions getCapabilities() { if (!APP_PATH.isSpecified()) { throw new IllegalStateException( "App path must be specified when using Electron!"); } ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary(APP_PATH.getValue()); return chromeOptions; }
private WebDriver getChromeWebDriver() { if (Boolean.parseBoolean(System.getenv(CIProperties.IS_TRAVIS))) { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary("/usr/bin/google-chrome-stable"); chromeOptions.setHeadless(true); chromeOptions.setCapability(SUPPORTS_JAVASCRIPT, true); return new ChromeDriver(chromeOptions); } else { return new ChromeDriver(); } }
private WebDriver getChromeWebDriver() { if (Boolean.parseBoolean(System.getenv(CIProperties.IS_TRAVIS))) { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary("/usr/bin/google-chrome-stable"); chromeOptions.setHeadless(true); chromeOptions.addArguments("--no-sandbox"); chromeOptions.setCapability(SUPPORTS_JAVASCRIPT, true); return new ChromeDriver(chromeOptions); } else { return new ChromeDriver(); } }
private ChromeOptions getLambdaChromeOptions() { ChromeOptions options = new ChromeOptions(); options.setBinary(getLibLocation("chrome")); options.addArguments("--disable-gpu"); options.addArguments("--headless"); options.addArguments("--window-size=1366,768"); options.addArguments("--single-process"); options.addArguments("--no-sandbox"); options.addArguments("--user-data-dir=/tmp/user-data"); options.addArguments("--data-path=/tmp/data-path"); options.addArguments("--homedir=/tmp"); options.addArguments("--disk-cache-dir=/tmp/cache-dir"); return options; }
private Capabilities chromeCapabilities(ChromeOptionsProperties chromeProperties) { ChromeOptions options = new ChromeOptions(); if (chromeProperties.getArgs() != null) options.addArguments(chromeProperties.getArgs()); if (chromeProperties.getBinary() != null) options.setBinary(chromeProperties.getBinary()); if (chromeProperties.getExtensions() != null) options.addExtensions(chromeProperties.getExtensions()); if (chromeProperties.getPreferences() != null) options.setExperimentalOption("prefs", chromeProperties.getPreferences()); return options; }