List of usage examples for org.openqa.selenium.chrome ChromeOptions CAPABILITY
String CAPABILITY
To view the source code for org.openqa.selenium.chrome ChromeOptions CAPABILITY.
Click Source Link
From source file:integration.io.github.seleniumquery.browser.driver.builders.ChromeDriverBuilderTest.java
License:Apache License
@Test public void withCapabilities() { // given/*from w ww. j a v a 2 s.c om*/ DesiredCapabilities capabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("start-maximized"); capabilities.setCapability(ChromeOptions.CAPABILITY, options); // when $.driver().useChrome().withCapabilities(capabilities); // then $.url(classNameToTestFileUrl(ChromeDriverBuilderTest.class)); assertThat($("#isMaximized").text(), is("yes")); }
From source file:io.openvidu.test.browsers.ChromeAndroidUser.java
License:Apache License
public ChromeAndroidUser(String userName, int timeOfWaitInSeconds) { super(userName, timeOfWaitInSeconds); Map<String, String> mobileEmulation = new HashMap<>(); mobileEmulation.put("deviceName", "Pixel 2"); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setAcceptInsecureCerts(true); capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions); // This flag avoids to grant the user media chromeOptions.addArguments("--use-fake-ui-for-media-stream"); // This flag fakes user media with synthetic video chromeOptions.addArguments("--use-fake-device-for-media-stream"); String REMOTE_URL = System.getProperty("REMOTE_URL_CHROME"); if (REMOTE_URL != null) { log.info("Using URL {} to connect to remote web driver", REMOTE_URL); try {/* w w w .j a va 2 s . c o m*/ this.driver = new RemoteWebDriver(new URL(REMOTE_URL), capabilities); } catch (MalformedURLException e) { e.printStackTrace(); } } else { log.info("Using local web driver"); this.driver = new ChromeDriver(capabilities); } this.driver.manage().timeouts().setScriptTimeout(this.timeOfWaitInSeconds, TimeUnit.SECONDS); this.configureDriver(); }
From source file:io.wcm.qa.galenium.webdriver.WebDriverManager.java
License:Apache License
private DesiredCapabilities getDesiredCapabilities(TestDevice newTestDevice) { DesiredCapabilities capabilities;//from ww w .jav a 2 s . co m GaleniumReportUtil.getLogger().info("Getting capabilities for " + newTestDevice.getBrowserType()); switch (newTestDevice.getBrowserType()) { case CHROME: capabilities = DesiredCapabilities.chrome(); String chromeEmulator = newTestDevice.getChromeEmulator(); if (chromeEmulator != null) { Map<String, String> mobileEmulation = new HashMap<String, String>(); mobileEmulation.put("deviceName", chromeEmulator); Map<String, Object> chromeOptions = new HashMap<String, Object>(); chromeOptions.put("mobileEmulation", mobileEmulation); capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions); } break; case IE: capabilities = DesiredCapabilities.internetExplorer(); break; case SAFARI: capabilities = DesiredCapabilities.safari(); break; case PHANTOMJS: capabilities = DesiredCapabilities.phantomjs(); capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] { "--ignore-ssl-errors=true", "--ssl-protocol=tlsv1", "--web-security=false", "--webdriver-loglevel=OFF", "--webdriver-loglevel=NONE" }); break; default: case FIREFOX: capabilities = DesiredCapabilities.firefox(); if (firefoxProfile == null) { firefoxProfile = new FirefoxProfile(); // Workaround for click events spuriously failing in Firefox (https://code.google.com/p/selenium/issues/detail?id=6112) firefoxProfile.setEnableNativeEvents(false); firefoxProfile.setAcceptUntrustedCertificates(true); firefoxProfile.setAssumeUntrustedCertificateIssuer(false); } capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile); break; } // Request browser logging capabilities for capturing console.log output LoggingPreferences loggingPrefs = new LoggingPreferences(); loggingPrefs.enable(LogType.BROWSER, Level.INFO); capabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPrefs); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); GaleniumReportUtil.getLogger().info("Done generating capabilities"); return capabilities; }
From source file:jp.igapyon.selecrawler.util.SimpleChromeWrapper.java
License:Open Source License
protected DesiredCapabilities getDesiredCapabilities() { final DesiredCapabilities capabilities = DesiredCapabilities.chrome(); {/*from w w w .ja v a2s . c o m*/ { final ChromeOptions chromeOptions = new ChromeOptions(); { final HashMap<String, Object> prefsMap = new HashMap<String, Object>(); prefsMap.put("profile.default_content_settings.popups", 0); // prefsMap.put("download.default_directory", ???); chromeOptions.setExperimentalOption("prefs", prefsMap); } if (DEVICE_IPHONE.equals(deviceName)) { final Map<String, String> mobileEmulationMap = new HashMap<String, String>(); mobileEmulationMap.put("deviceName", "Apple iPhone 6"); chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulationMap); } if (userDataDir != null && userDataDir.trim().length() > 0) { chromeOptions.addArguments("user-data-dir=" + userDataDir); } capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions); } } { capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); } { final LoggingPreferences preferences = new LoggingPreferences(); preferences.enable(LogType.BROWSER, Level.ALL); capabilities.setCapability(CapabilityType.LOGGING_PREFS, preferences); } return capabilities; }
From source file:mooltipass.AftBase.java
License:Open Source License
@BeforeClass public static void beforeClass() throws Exception { chromeDriverService = chromeDriverService(); if (chromeDriverService != null) { chromeDriverService.start();/*ww w . ja va 2s . c o m*/ } ChromeOptions options = new ChromeOptions(); // Appears you can only load one unpacked extensions this way... // list doesn't do it // List<String> arguments = new LinkedList<String>(); // arguments.add("load-extension=" + System.getProperty(MOOLTIPASS_DIR) + File.separator + "authentication_clients" + File.separator + "chrome.hid-app"); // arguments.add("load-extension=" + System.getProperty(MOOLTIPASS_DIR) + File.separator + "authentication_clients" + File.separator + "chrome-ext"); // options.addArguments(arguments); // comma delimited as some chrome arguments use doesn't work // options.addArguments("load-extension=" + System.getProperty(MOOLTIPASS_DIR) + File.separator + "authentication_clients" + File.separator + "chrome.hid-app","load-extension=" + System.getProperty(MOOLTIPASS_DIR) + File.separator + "authentication_clients" + File.separator + "chrome-ext"); // String... doesn't work // options.addArguments("load-extension=" + System.getProperty(MOOLTIPASS_DIR) + File.separator + "authentication_clients" + File.separator + "chrome.hid-app," + System.getProperty(MOOLTIPASS_DIR) + File.separator + "authentication_clients" + File.separator + "chrome-ext"); // Requires extensions are crx (zip file with public and private keys) // List extensions = new LinkedList(); // extensions.add(new File(System.getProperty(MOOLTIPASS_DIR) + File.separator + "authentication_clients" + File.separator + "chrome.hid-app")); // extensions.add(new File(System.getProperty(MOOLTIPASS_DIR) + File.separator + "authentication_clients" + File.separator + "chrome-ext")); // options.addExtensions(extensions); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(ChromeOptions.CAPABILITY, options); System.out.println("Starting an instance of chrome."); driver = new ChromeDriver(capabilities); // TODO figure out how to pre-install extensions automatically (see commented out code above for things that don't work) driver.get("chrome://extensions/"); System.out.println( "\nWaiting " + getTimeoutExtension() / 1000 + " seconds for you to install Extensions manually."); System.out.println( "Check the Developer mode checkbox and then use the Load unpackaged extensions to load the mooltipass authentication_clients chrome.hid-app and chrome.ext\n"); try { Thread.sleep(getTimeoutExtension()); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:net.codestory.simplelenium.driver.chrome.ChromeDriverDownloader.java
License:Apache License
protected ChromeDriver createNewChromeDriver(File chromeDriverExe, Capabilities desiredCapabilities) { ChromeDriverService chromeDriverService = new ChromeDriverService.Builder() .usingDriverExecutable(chromeDriverExe) // Use any port free or the one enforced by CHROME_DRIVER_PORT property .usingPort(Configuration.CHROMEDRIVER_PORT.getInt()).build(); DesiredCapabilities capabilities = new DesiredCapabilities( singletonMap(ChromeOptions.CAPABILITY, getChromeOptions())).merge(desiredCapabilities); return new ChromeDriver(chromeDriverService, capabilities); }
From source file:net.continuumsecurity.web.drivers.DriverFactory.java
License:Open Source License
public WebDriver createChromeDriver(DesiredCapabilities capabilities) { System.setProperty("webdriver.chrome.driver", Config.getInstance().getDefaultDriverPath()); if (capabilities != null) { capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); ChromeOptions options = new ChromeOptions(); options.addArguments("--test-type"); capabilities.setCapability(ChromeOptions.CAPABILITY, options); return new ChromeDriver(capabilities); } else/*from www. j av a 2 s . c o m*/ return new ChromeDriver(); }
From source file:openpath.Main.java
public void other(String[] args) throws IOException { String webdriverPath = "/usr/local/bin/chromedriver"; String chromePath = "/usr/bin/google-chrome"; String downloadDir = "/opt/tmp/openpath"; ChromeDriverService service = new ChromeDriverService.Builder() .usingDriverExecutable(new File(webdriverPath)).usingAnyFreePort().build(); Map<String, Object> prefs = new HashMap<>(); prefs.put("download.default_directory", downloadDir); ChromeOptions opts = new ChromeOptions(); opts.setBinary(new File(chromePath)); opts.setExperimentalOption("prefs", prefs); DesiredCapabilities caps = DesiredCapabilities.chrome(); caps.setCapability(ChromeOptions.CAPABILITY, opts); service.start();//www .java 2 s .co m WebDriver drv = new RemoteWebDriver(service.getUrl(), caps); OpenPathDriver opDrv = new OpenPathDriver(drv, m -> { System.out.println(">> " + m); }); String opUsername = "caiyuhao0125@hotmail.com"; String opPassword = "19910125"; opDrv.download(opUsername, opPassword, Paths.get(downloadDir)); service.stop(); System.exit(0); }
From source file:org.alfresco.grid.WebDriverFactory.java
License:Open Source License
public WebDriver getObject(Browser browser) { switch (browser) { case FireFox: return getFireFox(false); case Chrome://from w w w . j a v a 2s . co m return getChromeDriver(); case HtmlUnit: return new HtmlUnitDriver(true); case IE: return getInternetExplorerDriver(); case Safari: return getSafariDriver(); case RemoteFireFox: DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setBrowserName(BrowserType.FIREFOX); capabilities.setJavascriptEnabled(true); FirefoxProfile profile = createProfile(); //The below two preferences added to disable the firefox auto update profile.setPreference("app.update.auto", false); profile.setPreference("app.update.enabled", false); profile.setEnableNativeEvents(true); capabilities.setCapability(FirefoxDriver.PROFILE, profile); return getRemoteDriver(capabilities); case RemoteChrome: DesiredCapabilities chromeCapabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("--kiosk"); chromeCapabilities.setCapability(ChromeOptions.CAPABILITY, options); return getRemoteDriver(chromeCapabilities); case RemoteIE: DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer(); ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); return getRemoteDriver(ieCapabilities); case FireFoxDownloadToDir: return getFireFox(true); default: throw new IllegalArgumentException("Invalid browser specified"); } }
From source file:org.aludratest.service.gui.web.selenium.selenium2.DefaultSeleniumWebDriverFactory.java
License:Apache License
private static DesiredCapabilities createChromeCaps() { DesiredCapabilities caps = DesiredCapabilities.chrome(); ChromeOptions opts = new ChromeOptions(); caps.setCapability(ChromeOptions.CAPABILITY, opts); return caps;//ww w .ja v a2s. c o m }