Java Code Examples for org.openqa.selenium.chrome.ChromeOptions#setHeadless()
The following examples show how to use
org.openqa.selenium.chrome.ChromeOptions#setHeadless() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BotWorker.java From JYTB with GNU General Public License v3.0 | 5 votes |
private void setChromeDriver() { ChromeOptions options = new ChromeOptions(); List<String> chromeOptions = new ArrayList<>(); LoggingPreferences logPrefs = new LoggingPreferences(); chromeOptions.add(String.format("--proxy-server=%s", proxies.getCurrentProxyModel().getIp())); chromeOptions.add(String.format("--user-agent=%s", userAgent.randomUA())); chromeOptions.add("--mute-audio"); logPrefs.enable(LogType.BROWSER, Level.ALL); logPrefs.enable(LogType.PERFORMANCE, Level.INFO); options.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); options.addArguments(chromeOptions); options.setBinary(this.driverLocation); options.setHeadless(true); // options.setProxy(this.proxies.getCurrentProxy()); options.setCapability("proxy", this.proxies.getCurrentProxy()); this.webDriver = new ChromeDriver(options); Log.WINFO(this.workerName, this.workerColor, "Chrome Driver Set."); }
Example 2
Source File: SelenideMultiTest.java From healenium-web with Apache License 2.0 | 5 votes |
@Override public WebDriver createDriver(DesiredCapabilities capabilities) { Configuration.timeout = 15000; WebDriverManager.chromedriver().setup(); capabilities.setBrowserName("chrome"); ChromeOptions options = new ChromeOptions(); options.setHeadless(true); options.merge(capabilities); WebDriver wd = new ChromeDriver(options); return SelfHealingDriver.create(wd); }
Example 3
Source File: SelenideTest.java From healenium-web with Apache License 2.0 | 5 votes |
@Override public WebDriver createDriver(DesiredCapabilities capabilities) { capabilities.setBrowserName("chrome"); ChromeOptions options = new ChromeOptions(); options.setHeadless(true); options.merge(capabilities); WebDriver wd = new ChromeDriver(options); return SelfHealingDriver.create(wd); }
Example 4
Source File: SelfHealingEngineTest.java From healenium-web with Apache License 2.0 | 5 votes |
@BeforeEach public void createDriver() { ChromeOptions options = new ChromeOptions(); options.setHeadless(true); WebDriver delegate = new ChromeDriver(options); Config config = ConfigFactory.parseResources("test.conf") .withValue("heal-enabled", ConfigValueFactory.fromAnyRef(true)).resolve(); SelfHealingEngine engine = new SelfHealingEngine(delegate, config); driver = SelfHealingDriver.create(engine); }
Example 5
Source File: HealTurnedOffTest.java From healenium-web with Apache License 2.0 | 5 votes |
@BeforeEach public void createDriver() { ChromeOptions options = new ChromeOptions(); options.setHeadless(true); WebDriver delegate = new ChromeDriver(options); Config config = ConfigFactory.load("test.conf"); SelfHealingEngine engine = new SelfHealingEngine(delegate, config); driver = SelfHealingDriver.create(engine); }
Example 6
Source File: SearchTestWithChromeHeadless.java From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License | 5 votes |
@BeforeMethod public void setup() { System.setProperty("webdriver.chrome.driver", "./src/test/resources/drivers/chromedriver"); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setHeadless(true); driver = new ChromeDriver(chromeOptions); driver.get("http://demo-store.seleniumacademy.com/"); }
Example 7
Source File: RegistrationAndAuthenticationE2ETest.java From webauthn4j-spring-security with Apache License 2.0 | 5 votes |
@Before public void setupTest() { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setHeadless(true); driver = new ChromeDriver(chromeOptions); wait = new WebDriverWait(driver, Duration.ofSeconds(5)); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); }
Example 8
Source File: CustomDriverProvider.java From akita with Apache License 2.0 | 5 votes |
/** * Устанавливает ChromeOptions для запуска google chrome эмулирующего работу мобильного устройства (по умолчанию nexus 5) * Название мобильного устройства (device) может быть задано через системные переменные * * @return ChromeOptions */ private ChromeOptions getMobileChromeOptions(DesiredCapabilities capabilities) { log.info("---------------run CustomMobileDriver---------------------"); String mobileDeviceName = loadSystemPropertyOrDefault("device", "Nexus 5"); ChromeOptions chromeOptions = new ChromeOptions().addArguments("disable-extensions", "test-type", "no-default-browser-check", "ignore-certificate-errors"); Map<String, String> mobileEmulation = new HashMap<>(); chromeOptions.setHeadless(getHeadless()); mobileEmulation.put("deviceName", mobileDeviceName); chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation); chromeOptions.merge(capabilities); return chromeOptions; }
Example 9
Source File: CustomDriverProvider.java From akita with Apache License 2.0 | 5 votes |
/** * Задает 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; }
Example 10
Source File: SeleniumExtension.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private WebDriver getChromeWebDriver() { if (System.getenv(CIProperties.CHROME_DRIVER) != null) { 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(); } }
Example 11
Source File: ChromeImpl.java From frameworkium-core with Apache License 2.0 | 5 votes |
@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; }
Example 12
Source File: InitDriver.java From healenium-web with Apache License 2.0 | 4 votes |
public static SelfHealingDriver getDriver(){ ChromeOptions options = new ChromeOptions(); options.setHeadless(true); WebDriver delegate = new ChromeDriver(options); return SelfHealingDriver.create(delegate); }
Example 13
Source File: WebDriverCapabilities.java From QVisual with Apache License 2.0 | 4 votes |
/** * List of Chromium Command Line Switches * http://peter.sh/experiments/chromium-command-line-switches/#disable-popup-blocking */ private void setupChrome() { HashMap<String, Object> prefs = new HashMap<>(); prefs.put("profile.default_content_setting_values.notifications", 2); prefs.put("profile.default_content_settings.popups", 0); prefs.put("download.default_directory", DOWNLOAD_DIRECTORY); prefs.put("download.prompt_for_download", false); prefs.put("profile.content_settings.pattern_pairs.*.multiple-automatic-downloads", 1); prefs.put("safebrowsing.enabled", true); prefs.put("plugins.always_open_pdf_externally", true); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setExperimentalOption("useAutomationExtension", false); chromeOptions.setExperimentalOption("prefs", prefs); chromeOptions.addArguments("allow-file-access"); chromeOptions.addArguments("allow-file-access-from-files"); chromeOptions.addArguments("disable-background-networking"); chromeOptions.addArguments("disable-background-timer-throttling"); chromeOptions.addArguments("disable-breakpad"); chromeOptions.addArguments("disable-child-account-detection"); chromeOptions.addArguments("disable-clear-browsing-data-counters"); chromeOptions.addArguments("disable-client-side-phishing-detection"); chromeOptions.addArguments("disable-cloud-import"); chromeOptions.addArguments("disable-component-cloud-policy"); chromeOptions.addArguments("disable-component-update"); chromeOptions.addArguments("disable-default-apps"); chromeOptions.addArguments("disable-download-notification"); chromeOptions.addArguments("disable-extensions"); chromeOptions.addArguments("disable-extensions-file-access-check"); chromeOptions.addArguments("disable-extensions-http-throttling"); chromeOptions.addArguments("disable-hang-monitor"); chromeOptions.addArguments("disable-infobars"); chromeOptions.addArguments("disable-popup-blocking"); chromeOptions.addArguments("disable-print-preview"); chromeOptions.addArguments("disable-prompt-on-repost"); chromeOptions.addArguments("disable-sync"); chromeOptions.addArguments("disable-translate"); chromeOptions.addArguments("disable-web-resources"); chromeOptions.addArguments("disable-web-security"); chromeOptions.addArguments("dns-prefetch-disable"); chromeOptions.addArguments("download-whole-document"); chromeOptions.addArguments("enable-logging"); chromeOptions.addArguments("enable-screenshot-testing-with-mode"); chromeOptions.addArguments("ignore-certificate-errors"); chromeOptions.addArguments("log-level=0"); chromeOptions.addArguments("metrics-recording-only"); chromeOptions.addArguments("mute-audio"); chromeOptions.addArguments("no-default-browser-check"); chromeOptions.addArguments("no-displaying-insecure-content"); chromeOptions.addArguments("no-experiments"); chromeOptions.addArguments("no-first-run"); chromeOptions.addArguments("no-sandbox"); chromeOptions.addArguments("no-service-autorun"); chromeOptions.addArguments("noerrdialogs"); chromeOptions.addArguments("password-store=basic"); chromeOptions.addArguments("reduce-security-for-testing"); chromeOptions.addArguments("safebrowsing-disable-auto-update"); chromeOptions.addArguments("safebrowsing-disable-download-protection"); chromeOptions.addArguments("safebrowsing-disable-extension-blacklist"); chromeOptions.addArguments("start-maximized"); chromeOptions.addArguments("test-type=webdriver"); chromeOptions.addArguments("use-mock-keychain"); chromeOptions.setHeadless(BROWSER_HEADLESS); capabilities.merge(chromeOptions); }
Example 14
Source File: ChromeDriverCreator.java From bobcat with Apache License 2.0 | 4 votes |
private ChromeOptions getOptions() { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setHeadless(headless); chromeOptions.setAcceptInsecureCerts(acceptInsecureCerts); return chromeOptions; }