List of usage examples for org.openqa.selenium Platform WIN8_1
Platform WIN8_1
To view the source code for org.openqa.selenium Platform WIN8_1.
Click Source Link
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
/** * This method build a RemoteWebDriver based on the passed in browser request * * @param browser// www . ja v a 2 s .c o m * @return RemoteWebDriver * */ private static RemoteWebDriver buildRemoteWebDriver(String browserName) { DesiredCapabilities capability = null; BrowserType browserType = BrowserType.getBrowserTypeFromString(browserName); switch (browserType) { case MARIONETTE: FirefoxProfile ffProfile = null; ffProfile = new FirefoxProfile(); ffProfile.setAcceptUntrustedCertificates(true); ffProfile.setAssumeUntrustedCertificateIssuer(false); DesiredCapabilities cap = DesiredCapabilities.firefox(); cap.setCapability("marionette", true); cap.setCapability("firefox_profile", ffProfile); cap.setCapability("handlesAlerts", true); sysEnv = System.getenv("webdriver.firefox.marionette"); if (sysEnv == null) { sysEnv = findFileName("C:/apps/selenium", "geckodriver.exe", FileSearchType.File); if (sysEnv == null) { log.info( "Please set the webdriver.firefox.marionette in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location"); throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName); } else { System.setProperty("webdriver.firefox.marionette", sysEnv); } } return new MarionetteDriver(capability); case FIREFOX_DRIVER: capability = DesiredCapabilities.firefox(); FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setAcceptUntrustedCertificates(true); firefoxProfile.setEnableNativeEvents(true); capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile); capability.setPlatform(capability.getPlatform()); capability.setVersion(capability.getVersion()); return new FirefoxDriver(capability); case CHROME_DRIVER: sysEnv = System.getenv("webdriver.chrome.driver"); if (sysEnv == null) { sysEnv = findFileName("C:/apps/selenium", "chromedriver.exe", FileSearchType.File); if (sysEnv == null) { log.info( "Please set the webdriver.chrome.driver in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location"); throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName); } else { System.setProperty("webdriver.chrome.driver", sysEnv); } } capability = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments(new String[] { "--allow-running-insecure-content" }); options.addArguments(new String[] { "--ignore-certificate-errors" }); options.addArguments(new String[] { "--enable-npapi" }); options.addArguments(new String[] { "--disable-extensions" }); options.addArguments(new String[] { "--start-maximized" }); capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); capability.setCapability(ChromeOptions.CAPABILITY, options); capability.setPlatform(capability.getPlatform()); capability.setVersion(capability.getVersion()); return new ChromeDriver(capability); case INTERNET_EXPLORER: sysEnv = System.getenv("webdriver.ie.driver"); if (sysEnv == null) { sysEnv = findFileName("C:/apps/selenium", "IEDriverServer.exe", FileSearchType.File); if (sysEnv == null) { log.info( "Please set the webdriver.ie.driver in system environment variables and restart the PC"); throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName); } else { System.setProperty("webdriver.ie.driver", sysEnv); } } capability = DesiredCapabilities.internetExplorer(); capability.setCapability("ignoreProtectedModeSettings", true); String browserVersion = capability.getVersion(); if (browserVersion != null && browserVersion.equals("10")) { capability.setPlatform(Platform.WINDOWS); capability.setVersion(browserVersion); } else if (browserVersion != null && browserVersion.equals("11")) { capability.setPlatform(Platform.WIN8_1); capability.setVersion(browserVersion); } capability.setBrowserName("internet explorer"); capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); return new InternetExplorerDriver(capability); case SAFARI: capability = DesiredCapabilities.safari(); capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); capability.setCapability("ensureCleanSession", true); capability.setPlatform(capability.getPlatform()); capability.setVersion(null); return new SafariDriver(capability); /* case OPERA_DRIVER: capability = DesiredCapabilities.opera(); capability.setCapability("opera.profile", "/test"); return new OperaDriver(); */ case EDGE: capability = DesiredCapabilities.edge(); EdgeOptions option = new EdgeOptions(); capability.setCapability("edgeOptions", option); return new EdgeDriver(capability); default: log.info( "Currenty support is there for Chrome, Firefox, Firefox Marionette, Internet Explorer, Edge, Safari & Opera. Support is not there for " + browserName); capability = DesiredCapabilities.firefox(); firefoxProfile = new FirefoxProfile(); firefoxProfile.setAcceptUntrustedCertificates(true); firefoxProfile.setEnableNativeEvents(true); capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile); capability.setPlatform(capability.getPlatform()); capability.setVersion(capability.getVersion()); return new FirefoxDriver(capability); } }
From source file:de.dentrassi.pm.testing.TestSuite.java
License:Open Source License
@BeforeClass public static void setupBrowser() throws MalformedURLException { if (hasSauce()) { driver = createSauce(Platform.WIN8_1, "chrome", null); } else {//from ww w . j a v a2 s. c o m driver = new FirefoxDriver(); } }
From source file:org.kurento.test.browser.Browser.java
License:Apache License
private void createChromeBrowser(DesiredCapabilities capabilities) throws MalformedURLException { // Chrome driver ChromeDriverManager.getInstance().setup(); // Chrome options ChromeOptions options = new ChromeOptions(); // Chrome extensions if (extensions != null && !extensions.isEmpty()) { for (Map<String, String> extension : extensions) { InputStream is = getExtensionAsInputStream(extension.values().iterator().next()); if (is != null) { try { File crx = File.createTempFile(extension.keySet().iterator().next(), ".crx"); FileUtils.copyInputStreamToFile(is, crx); options.addExtensions(crx); } catch (Throwable t) { log.error("Error loading Chrome extension {} ({} : {})", extension, t.getClass(), t.getMessage()); }/* w w w . ja v a2 s. c o m*/ } } } if (enableScreenCapture) { // This flag enables the screen sharing options.addArguments("--enable-usermedia-screen-capturing"); String windowTitle = TEST_SCREEN_SHARE_TITLE_DEFAULT; if (platform != null && (platform == Platform.WINDOWS || platform == Platform.XP || platform == Platform.VISTA || platform == Platform.WIN8 || platform == Platform.WIN8_1)) { windowTitle = TEST_SCREEN_SHARE_TITLE_DEFAULT_WIN; } options.addArguments("--auto-select-desktop-capture-source=" + getProperty(TEST_SCREEN_SHARE_TITLE_PROPERTY, windowTitle)); } else { // This flag avoids grant the camera options.addArguments("--use-fake-ui-for-media-stream"); } // This flag avoids warning in Chrome. See: // https://code.google.com/p/chromedriver/issues/detail?id=799 options.addArguments("--test-type"); if (protocol == Protocol.FILE) { // This flag allows reading local files in video tags options.addArguments("--allow-file-access-from-files"); } if (!usePhysicalCam) { // This flag makes using a synthetic video (green with // spinner) in WebRTC. Or it is needed to combine with // use-file-for-fake-video-capture to use a file faking the // cam options.addArguments("--use-fake-device-for-media-stream=fps=30"); if (video != null && (isLocal() || isDocker())) { if (!Files.exists(Paths.get(video))) { throw new RuntimeException("Trying to create a browser using video file " + video + ", but this file doesn't exist."); } log.debug("Using video {} in browser {}", video, id); options.addArguments("--use-file-for-fake-video-capture=" + video); } } capabilities.setCapability(ChromeOptions.CAPABILITY, options); capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName()); createDriver(capabilities, options); }
From source file:org.kurento.test.client.BrowserClient.java
License:Open Source License
public void init() { Class<? extends WebDriver> driverClass = browserType.getDriverClass(); try {/*from www . j a va 2 s . c om*/ DesiredCapabilities capabilities = new DesiredCapabilities(); if (driverClass.equals(FirefoxDriver.class)) { FirefoxProfile profile = new FirefoxProfile(); // This flag avoids granting the access to the camera profile.setPreference("media.navigator.permission.disabled", true); capabilities.setCapability(FirefoxDriver.PROFILE, profile); capabilities.setBrowserName(DesiredCapabilities.firefox().getBrowserName()); // Firefox extensions if (extensions != null && !extensions.isEmpty()) { for (Map<String, String> extension : extensions) { InputStream is = getExtensionAsInputStream(extension.values().iterator().next()); if (is != null) { try { File xpi = File.createTempFile(extension.keySet().iterator().next(), ".xpi"); FileUtils.copyInputStreamToFile(is, xpi); profile.addExtension(xpi); } catch (Throwable t) { log.error("Error loading Firefox extension {} ({} : {})", extension, t.getClass(), t.getMessage()); } } } } if (scope == BrowserScope.SAUCELABS) { createSaucelabsDriver(capabilities); } else if (scope == BrowserScope.REMOTE) { createRemoteDriver(capabilities); } else { driver = new FirefoxDriver(profile); } } else if (driverClass.equals(ChromeDriver.class)) { // Chrome driver ChromeDriverManager.getInstance().setup(); // Chrome options ChromeOptions options = new ChromeOptions(); // Chrome extensions if (extensions != null && !extensions.isEmpty()) { for (Map<String, String> extension : extensions) { InputStream is = getExtensionAsInputStream(extension.values().iterator().next()); if (is != null) { try { File crx = File.createTempFile(extension.keySet().iterator().next(), ".crx"); FileUtils.copyInputStreamToFile(is, crx); options.addExtensions(crx); } catch (Throwable t) { log.error("Error loading Chrome extension {} ({} : {})", extension, t.getClass(), t.getMessage()); } } } } if (enableScreenCapture) { // This flag enables the screen sharing options.addArguments("--enable-usermedia-screen-capturing"); String windowTitle = TEST_SCREEN_SHARE_TITLE_DEFAULT; if (platform != null && (platform == Platform.WINDOWS || platform == Platform.XP || platform == Platform.VISTA || platform == Platform.WIN8 || platform == Platform.WIN8_1)) { windowTitle = TEST_SCREEN_SHARE_TITLE_DEFAULT_WIN; } options.addArguments("--auto-select-desktop-capture-source=" + getProperty(TEST_SCREEN_SHARE_TITLE_PROPERTY, windowTitle)); } else { // This flag avoids grant the camera options.addArguments("--use-fake-ui-for-media-stream"); } // This flag avoids warning in Chrome. See: // https://code.google.com/p/chromedriver/issues/detail?id=799 options.addArguments("--test-type"); if (protocol == Protocol.FILE) { // This flag allows reading local files in video tags options.addArguments("--allow-file-access-from-files"); } if (!usePhysicalCam) { // This flag makes using a synthetic video (green with // spinner) in WebRTC. Or it is needed to combine with // use-file-for-fake-video-capture to use a file faking the // cam options.addArguments("--use-fake-device-for-media-stream"); if (video != null && isLocal()) { options.addArguments("--use-file-for-fake-video-capture=" + video); } } capabilities.setCapability(ChromeOptions.CAPABILITY, options); capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName()); if (scope == BrowserScope.SAUCELABS) { createSaucelabsDriver(capabilities); } else if (scope == BrowserScope.REMOTE) { createRemoteDriver(capabilities); } else { driver = new ChromeDriver(options); } } else if (driverClass.equals(InternetExplorerDriver.class)) { if (scope == BrowserScope.SAUCELABS) { capabilities.setBrowserName(DesiredCapabilities.internetExplorer().getBrowserName()); capabilities.setCapability("ignoreProtectedModeSettings", true); createSaucelabsDriver(capabilities); } } else if (driverClass.equals(SafariDriver.class)) { if (scope == BrowserScope.SAUCELABS) { capabilities.setBrowserName(DesiredCapabilities.safari().getBrowserName()); createSaucelabsDriver(capabilities); } } // Timeouts changeTimeout(timeout); if (protocol == Protocol.FILE) { String clientPage = client.toString(); File clientPageFile = new File( this.getClass().getClassLoader().getResource("static" + clientPage).getFile()); url = protocol.toString() + clientPageFile.getAbsolutePath(); } else { String hostName = host != null ? host : node; url = protocol.toString() + hostName + ":" + serverPort + client.toString(); } log.info("*** Browsing URL with WebDriver: {}", url); driver.get(url); } catch (MalformedURLException e) { log.error("MalformedURLException in BrowserClient.initDriver", e); } // startPing(); }
From source file:org.kurento.test.compatibility.webrtc.WebRtcCompatibilityLoopbackTest.java
License:Open Source License
@Parameters(name = "{index}: {0}") public static Collection<Object[]> data() { // Test: Browsers in saucelabs TestScenario test1 = new TestScenario(); test1.addBrowser(BrowserConfig.BROWSER, new BrowserClient.Builder().browserType(BrowserType.CHROME).scope(BrowserScope.SAUCELABS) .client(Client.WEBRTC).platform(Platform.WIN8_1).browserVersion("39").build()); return Arrays.asList(new Object[][] { { test1 } }); }
From source file:org.kurento.test.compatibility.webrtc.WebRtcCompatibilityPlaybackTest.java
License:Open Source License
@Parameters(name = "{index}: {0}") public static Collection<Object[]> data() { // Test: Browsers in saucelabs TestScenario test1 = new TestScenario(); test1.addBrowser(BrowserConfig.BROWSER, new BrowserClient.Builder().client(Client.WEBRTC).browserType(BrowserType.CHROME) .scope(BrowserScope.SAUCELABS).platform(Platform.WIN8_1).browserVersion("39").build()); TestScenario test2 = new TestScenario(); test2.addBrowser(BrowserConfig.BROWSER, new BrowserClient.Builder().client(Client.WEBRTC).browserType(BrowserType.FIREFOX) .scope(BrowserScope.SAUCELABS).platform(Platform.LINUX).browserVersion("35").build()); return Arrays.asList(new Object[][] { { test1 }, { test2 } }); }