List of usage examples for org.openqa.selenium Platform WINDOWS
Platform WINDOWS
To view the source code for org.openqa.selenium Platform WINDOWS.
Click Source Link
From source file:io.appium.java_client.service.local.AppiumServiceBuilder.java
License:Apache License
private static String defineNodeCommandPrefix() { if (Platform.getCurrent().is(Platform.WINDOWS)) return "cmd.exe /C"; else//from www .j a va2 s.c o m return "/bin/bash -l -c"; }
From source file:minium.web.config.services.DriverServicesProperties.java
License:Apache License
protected File findExecutable(String exeName) { File driversDir = getDriversDir(); if (driversDir == null) return null; String osSpecificExeName = Platform.getCurrent().is(Platform.WINDOWS) ? exeName + ".exe" : exeName; File exeFile = new File(driversDir, osSpecificExeName); return exeFile.exists() && exeFile.isFile() && exeFile.canExecute() ? exeFile : null; }
From source file:org.cerberus.serviceEngine.impl.SeleniumService.java
License:Open Source License
public DesiredCapabilities setCapabilityPlatform(DesiredCapabilities capabilities, String platform) throws CerberusException { if (platform.equalsIgnoreCase("WINDOWS")) { capabilities.setPlatform(Platform.WINDOWS); } else if (platform.equalsIgnoreCase("LINUX")) { capabilities.setPlatform(Platform.LINUX); } else if (platform.equalsIgnoreCase("ANDROID")) { capabilities.setPlatform(Platform.ANDROID); } else if (platform.equalsIgnoreCase("MAC")) { capabilities.setPlatform(Platform.MAC); } else if (platform.equalsIgnoreCase("UNIX")) { capabilities.setPlatform(Platform.UNIX); } else if (platform.equalsIgnoreCase("VISTA")) { capabilities.setPlatform(Platform.VISTA); } else if (platform.equalsIgnoreCase("WIN8")) { capabilities.setPlatform(Platform.WIN8); } else if (platform.equalsIgnoreCase("XP")) { capabilities.setPlatform(Platform.XP); } else {//from w ww . j a va2 s. c om capabilities.setPlatform(Platform.ANY); } return capabilities; }
From source file:org.emonocot.portal.driver.WebDriverFacade.java
License:Open Source License
/** * * @return the webdriver//from w w w.ja v a 2s . c om * @throws IOException if there is a problem loading the * properties file */ private WebDriver createWebDriver() throws IOException { Resource propertiesFile = new ClassPathResource("META-INF/spring/application.properties"); Properties properties = new Properties(); properties.load(propertiesFile.getInputStream()); String webdriverMode = properties.getProperty("selenium.webdriver.mode", "local"); String driverName = properties.getProperty("selenium.webdriver.impl", "org.openqa.selenium.firefox.FirefoxDriver"); WebDriverBrowserType browser = WebDriverBrowserType.fromString(driverName); String display = properties.getProperty("selenium.display.port", ":0"); if (webdriverMode.equals("local")) { switch (browser) { case CHROME: String chromeLocation = properties.getProperty("selenium.webdriver.chromedriver.location"); Map<String, String> environment = new HashMap<String, String>(); environment.put("DISPLAY", display); ChromeDriverService chromeService = new ChromeDriverService.Builder() .usingDriverExecutable(new File(chromeLocation)).usingAnyFreePort() .withEnvironment(environment).build(); chromeService.start(); return new RemoteWebDriver(chromeService.getUrl(), DesiredCapabilities.chrome()); case SAFARI: return new SafariDriver(); case INTERNET_EXPLORER: String internetExplorerLocation = properties.getProperty("selenium.webdriver.ie.location"); InternetExplorerDriverService ieService = InternetExplorerDriverService.createDefaultService(); ieService.start(); return new RemoteWebDriver(ieService.getUrl(), DesiredCapabilities.internetExplorer()); case FIREFOX: default: FirefoxBinary firefoxBinary = new FirefoxBinary(); firefoxBinary.setEnvironmentProperty("DISPLAY", display); ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile profile = allProfiles.getProfile("default"); return new FirefoxDriver(firefoxBinary, profile); } } else { DesiredCapabilities capabilities = new DesiredCapabilities(); switch (browser) { case CHROME: capabilities = DesiredCapabilities.chrome(); break; case INTERNET_EXPLORER: capabilities = DesiredCapabilities.internetExplorer(); break; case SAFARI: capabilities = DesiredCapabilities.safari(); break; case FIREFOX: default: capabilities = DesiredCapabilities.firefox(); } String platformName = properties.getProperty("selenium.webdriver.platformName", "LINUX"); WebDriverPlatformType platform = WebDriverPlatformType.valueOf(platformName); switch (platform) { case MAC: capabilities.setPlatform(Platform.MAC); break; case WINDOWS: capabilities.setPlatform(Platform.WINDOWS); break; case LINUX: default: capabilities.setPlatform(Platform.LINUX); } return new RemoteWebDriver(new URL("http://build.e-monocot.org:4444/wd/hub"), capabilities); } }
From source file:org.fluentlenium.integration.localtest.SauceLabsFluentCase.java
License:Apache License
@Override public WebDriver getDefaultDriver() { DesiredCapabilities capabilities = new DesiredCapabilities("firefox", "3.6.", Platform.WINDOWS); capabilities.setCapability("name", "Test of FluentLenium"); try {// w w w. j a va 2 s. co m return new RemoteWebDriver(new URL( "http://fluentlenium:8906940f-5638-4c29-beb6-c331df039f48@ondemand.saucelabs.com:80/wd/hub"), capabilities); } catch (MalformedURLException e) { return null; } }
From source file:org.glassfish.tyrus.tests.qa.SeleniumToolkit.java
License:Open Source License
public static boolean onWindows() { return Platform.WINDOWS.is(Platform.getCurrent()); }
From source file:org.integration.FluentLeniumWaitOnLabsTest.java
License:Apache License
@Override public WebDriver getDefaultDriver() { DesiredCapabilities capabillities = new DesiredCapabilities("firefox", "3.6.", Platform.WINDOWS); capabillities.setCapability("name", "Test of FluentLenium"); WebDriver driver = null;// w w w .j av a 2 s.c om try { driver = new RemoteWebDriver(new URL( "http://fluentlenium:8906940f-5638-4c29-beb6-c331df039f48@ondemand.saucelabs.com:80/wd/hub"), capabillities); } catch (MalformedURLException e) { } return driver; }
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 ww . j a v a2s . 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 {// w ww. ja v a 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.openecomp.sdc.ci.tests.execute.setup.RemoteWebDriverTest.java
License:Open Source License
public void remoteTest() throws Exception { DesiredCapabilities cap = new DesiredCapabilities().firefox(); cap.setPlatform(Platform.WINDOWS); cap.setBrowserName("firefox"); RemoteWebDriver remoteDriver = new RemoteWebDriver(new URL("http://1.2.3.4:5555/wd/hub"), cap); remoteDriver.navigate().to("http://www.google.co.il"); remoteDriver.findElementByName("q").sendKeys("execute automation"); remoteDriver.findElementByName("btnK").click(); }