System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("--disable-extensions"); driver = new ChromeDriver(options);
/** * This method only handles so-called "arguments" and "preferences" * for ChromeOptions (there is also "Extensions" etc.) * * @param currentChromeOptions * @return options updated with args & prefs parameters */ private ChromeOptions transferChromeOptionsFromSystemProperties(ChromeOptions currentChromeOptions) { if (System.getProperty("chromeoptions.args") != null) { Stream<String> params = Arrays.stream(parseCSVhandlingQuotes(System.getProperty("chromeoptions.args"))); List<String> args = params .map(s -> s.replace("\"", "")) .collect(Collectors.toList()); currentChromeOptions.addArguments(args); } if (System.getProperty("chromeoptions.prefs") != null) { Map<String, Object> prefs = parsePreferencesFromString(System.getProperty("chromeoptions.prefs")); currentChromeOptions.setExperimentalOption("prefs", prefs); } return currentChromeOptions; }
private void setUpWebDriver() { ChromeOptions options = new ChromeOptions(); options.addArguments("headless"); options.addArguments("no-sandbox"); options.addArguments("window-size=1200x600"); driver = new ChromeDriver(options); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(300, TimeUnit.SECONDS); }
@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; }
System.setProperty("webdriver.chrome.driver","<<your chrome path>>"); // To remove message "You are using an unsupported command-line flag: --ignore-certificate-errors. // Stability and security will suffer." // Add an argument 'test-type' DesiredCapabilities capabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("test-type"); capabilities.setCapability("chrome.binary","<<your chrome path>>"); capabilities.setCapability(ChromeOptions.CAPABILITY, options); driver = new ChromeDriver(capabilities);
ChromeOptions options = new ChromeOptions(); options.addArguments("-incognito"); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(ChromeOptions.CAPABILITY, options);
options.addArguments("--allow-file-access-from-files"); return new ChromeDriver(options);
/** * @param arguments The arguments to use when starting Chrome. * @see #addArguments(java.util.List) */ public ChromeOptions addArguments(String... arguments) { addArguments(ImmutableList.copyOf(arguments)); return this; }
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data"); options.addArguments("--start-maximized"); driver = new ChromeDriver(options);
String userProfile= "C:\\Users\\user_name\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\"; ChromeOptions options = new ChromeOptions(); options.addArguments("user-data-dir="+userProfile); options.addArguments("--start-maximized"); WebDriver driver = new ChromeDriver(options); driver.get("http://www.google.com");
ChromeOptions options = new ChromeOptions(); options.addArguments("test-type"); options.addArguments("disable-popup-blocking"); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(ChromeOptions.CAPABILITY, options); WebDriver driver = new ChromeDriver(capabilities);
public WebDriver getDriver(String locale){ System.setProperty("webdriver.chrome.driver", "driver/chromedriver.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("--lang=" + locale); return new ChromeDriver(options); } public void initializeSelenium() throws Exception{ driver = getDriver("es"); // two letters to represent the locale, or two letters + country }
DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("user-data-dir=C:\\Users\\"+System.getenv("USERNAME")+"\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 1"); desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options); driver = new ChromeDriver(desiredCapabilities);
System.setProperty("webdriver.chrome.driver","./src\\lib\\chromedriver.exe"); ChromeOptions options= new ChromeOptions(); options.addArguments("--no-startup-window"); //I tried this line also: options.addArguments("--silent-launch"); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(ChromeOptions.CAPABILITY, options); WebDriver driver = new ChromeDriver(capabilities);
public TestDependencyGraphReportUtil() { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--headless"); this.driver = new ChromeDriver(chromeOptions); }
System.setProperty("webdriver.chrome.driver","<<your chrome path>>"); // To remove message "You are using an unsupported command-line flag: --ignore-certificate-errors. // Stability and security will suffer." // Add an argument 'test-type' DesiredCapabilities capabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("test-type"); capabilities.setCapability("chrome.binary","<<your chrome path>>"); capabilities.setCapability(ChromeOptions.CAPABILITY, options); driver = new ChromeDriver(capabilities);
void beforeInitialize(Capabilities capabilities){ if(capabilities.getBrowserName().equalIgnorCase("chrome"){ ChromeOptions options = new ChromeOptions(); options.addArguments("--start-maximized"); ((DesiredCapabilities)capabilities).setCapability(ChromeOptions.CAPABILITY, options); } } void onInitialize(QAFExtendedWebDriver driver){ //for browser other than chrome... driver.manage().window().maximize(); }
private void addRuntimeOptionsTo(ChromeOptions options) { if (ThucydidesSystemProperty.USE_CHROME_AUTOMATION_OPTIONS.booleanFrom(environmentVariables,true)) { options.addArguments(AUTOMATION_OPTIONS); } if (StringUtils.isNotEmpty(driverOptions)) { List<String> arguments = new OptionsSplitter().split(driverOptions); options.addArguments(arguments); } options.setAcceptInsecureCerts(ACCEPT_INSECURE_CERTIFICATES.booleanFrom(environmentVariables, false)); }
private WebDriver createHeadlessChromeDriver() { ChromeOptions options = new ChromeOptions(); options.addArguments("--headless", "--disable-gpu"); return TestBench.createDriver(new ChromeDriver(options)); }
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); }