@Bean(destroyMethod = "quit") public ChromeDriver webDriver() { System.setProperty("webdriver.chrome.logfile", "/tmp/chromedriver.log"); System.setProperty("webdriver.chrome.verboseLogging", "true"); ChromeOptions options = new ChromeOptions(); options.addArguments( "--verbose", "--headless", "--disable-web-security", "--ignore-certificate-errors", "--allow-running-insecure-content", "--allow-insecure-localhost", "--no-sandbox", "--disable-gpu" ); LoggingPreferences logs = new LoggingPreferences(); logs.enable(LogType.PERFORMANCE, Level.ALL); options.setCapability(CapabilityType.LOGGING_PREFS, logs); options.setAcceptInsecureCerts(true); ChromeDriver driver = new ChromeDriver(options); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS); driver.manage().timeouts().setScriptTimeout(15, TimeUnit.SECONDS); driver.manage().window().setSize(new Dimension(1024, 768)); return driver; }
public ChromeOptions setUnhandledPromptBehaviour(UnexpectedAlertBehaviour behaviour) { setCapability(UNHANDLED_PROMPT_BEHAVIOUR, behaviour); setCapability(UNEXPECTED_ALERT_BEHAVIOUR, behaviour); return this; }
public ChromeOptions setPageLoadStrategy(PageLoadStrategy strategy) { setCapability(PAGE_LOAD_STRATEGY, strategy); return this; }
/** * Returns ChromeOptions with the capability ACCEPT_INSECURE_CERTS set. * @param acceptInsecureCerts * @return ChromeOptions */ public ChromeOptions setAcceptInsecureCerts(boolean acceptInsecureCerts) { setCapability(ACCEPT_INSECURE_CERTS, acceptInsecureCerts); return this; }
public ChromeOptions setProxy(Proxy proxy) { setCapability(CapabilityType.PROXY, proxy); return this; }
public ChromeOptions() { setCapability(CapabilityType.BROWSER_NAME, BrowserType.CHROME); }
@Override public ChromeOptions getCapabilities() { ChromeOptions chromeOptions = new ChromeOptions(); // useful defaults chromeOptions.setCapability( "chrome.switches", Collections.singletonList("--no-default-browser-check")); chromeOptions.setCapability( "chrome.prefs", ImmutableMap.of("profile.password_manager_enabled", "false")); // Workaround Docker/Travis issue if (Boolean.parseBoolean(System.getenv("CHROME_NO_SANDBOX"))) { chromeOptions.addArguments("--no-sandbox"); } // Use Chrome's built in device emulators if (Property.DEVICE.isSpecified()) { chromeOptions.setExperimentalOption( "mobileEmulation", ImmutableMap.of("deviceName", Property.DEVICE.getValue())); } chromeOptions.setHeadless(Property.HEADLESS.getBoolean()); return chromeOptions; }
/** * Задает options для запуска Chrome драйвера * options можно передавать, как системную переменную, например -Doptions=--load-extension=my-custom-extension * @return ChromeOptions */ private ChromeOptions getChromeDriverOptions(DesiredCapabilities capabilities) { log.info("---------------Chrome Driver---------------------"); ChromeOptions chromeOptions = !options[0].equals("") ? new ChromeOptions().addArguments(options) : new ChromeOptions(); chromeOptions.setCapability(CapabilityType.BROWSER_VERSION, loadSystemPropertyOrDefault(CapabilityType.BROWSER_VERSION, VERSION_LATEST)); chromeOptions.setHeadless(getHeadless()); chromeOptions.merge(capabilities); return chromeOptions; }
theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences);
@Override protected ChromeOptions getDefaultOptions(Proxy proxy) { ChromeOptions options = new ChromeOptions(); options.addArguments("test-type"); options.addArguments("disable-popup-blocking"); options.addArguments("ignore-certificate-errors"); options.addArguments("disable-translate"); if (proxy != null) { options.setCapability(CapabilityType.PROXY, proxy); } return options; }
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(); } }
options.setCapability(PROXY, proxy); options.setCapability(ACCEPT_SSL_CERTS, drAcceptSsl); options.setCapability(SUPPORTS_APPLICATION_CACHE, drSupportCache); options.setCapability(SUPPORTS_ALERTS, drAlertsHandled);
private WebDriver newDriverForTest() { final ChromeOptions theOptions = new ChromeOptions().setHeadless(true); theOptions.addArguments("--js-flags=experimental-wasm-eh"); theOptions.addArguments("--enable-experimental-wasm-eh"); final LoggingPreferences theLoggingPreferences = new LoggingPreferences(); theLoggingPreferences.enable(LogType.BROWSER, Level.ALL); theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences); final DesiredCapabilities theCapabilities = DesiredCapabilities.chrome(); theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions); return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities); }
private WebDriver newDriverForTest() { final ChromeOptions theOptions = new ChromeOptions().setHeadless(true); theOptions.addArguments("--js-flags=experimental-wasm-eh"); theOptions.addArguments("--enable-experimental-wasm-eh"); final LoggingPreferences theLoggingPreferences = new LoggingPreferences(); theLoggingPreferences.enable(LogType.BROWSER, Level.ALL); theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences); final DesiredCapabilities theCapabilities = DesiredCapabilities.chrome(); theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions); return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities); }
proxy.setHttpProxy(proxyServer); options.setCapability(CapabilityType.PROXY, proxy);