Example usage for org.openqa.selenium Platform VISTA

List of usage examples for org.openqa.selenium Platform VISTA

Introduction

In this page you can find the example usage for org.openqa.selenium Platform VISTA.

Prototype

Platform VISTA

To view the source code for org.openqa.selenium Platform VISTA.

Click Source Link

Document

For versions of Windows that "feel like" Windows Vista.

Usage

From source file:com.vaadin.testbench.parallel.BrowserUtil.java

/**
 * Returns a human readable identifier of the platform described by the
 * given capabilities. Used mainly for screenshots
 *
 * @param capabilities//ww  w .  jav  a  2 s. c  o m
 * @return a human readable string describing the platform
 */
public static String getPlatform(Capabilities capabilities) {
    if (capabilities == null) {
        return "Unknown";
    }
    try {
        Platform p = capabilities.getPlatform();
        if (p == Platform.WIN8 || p == Platform.WINDOWS || p == Platform.VISTA || p == Platform.XP) {
            return "Windows";
        } else if (p == Platform.MAC) {
            return "Mac";
        }

    } catch (Exception e) {
    }
    Object rawPlatform = capabilities.getCapability(CapabilityType.PLATFORM);
    if (rawPlatform == null) {
        return "Unknown";
    }
    return rawPlatform.toString();
}

From source file:com.zaizi.automation.alfresco.core.info.TestCaseProperties.java

License:Open Source License

public static WebDriver gridDriver(String browser, String operatingSystem) throws MalformedURLException {
    if (driver != null) {
        closeDriver(driver);//from   www.j  av  a2  s  .  c  om
    }
    if ("Firefox".equals(browser) && "MAC".equals(operatingSystem)) {
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        capability.setBrowserName("firefox");
        capability.setCapability("ignoreZoomSetting", true);
        capability.setPlatform(Platform.MAC);
        capability.setVersion("ANY");
        capability.setCapability("nativeEvents", false);
        driver = new RemoteWebDriver(new URL(FFNODEURL), capability);
    } else if ("Firefox".equals(browser) && "VISTA".equals(operatingSystem)) {
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        capability.setBrowserName("firefox");
        capability.setCapability("ignoreZoomSetting", true);
        capability.setPlatform(Platform.VISTA);
        capability.setVersion("ANY");
        capability.setCapability("nativeEvents", false);
        driver = new RemoteWebDriver(new URL(FFNODEURL), capability);
    } else if ("Firefox".equals(browser) && "WINDOWS".equals(operatingSystem)) {
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        capability.setBrowserName("firefox");
        capability.setCapability("ignoreZoomSetting", true);
        capability.setPlatform(Platform.WINDOWS);
        capability.setVersion("ANY");
        capability.setCapability("nativeEvents", false);
        driver = new RemoteWebDriver(new URL(FFNODEURL), capability);
    } else if ("Chrome".equals(browser) && "VISTA".equals(operatingSystem)) {
        DesiredCapabilities capability = DesiredCapabilities.chrome();
        capability.setBrowserName("chrome");
        capability.setCapability("ignoreZoomSetting", true);
        capability.setPlatform(Platform.VISTA);
        capability.setVersion("ANY");
        capability.setCapability("nativeEvents", false);
        driver = new RemoteWebDriver(new URL(CHROMENODEURL), capability);
    } else if ("Chrome".equals(browser) && "MAC".equals(operatingSystem)) {
        DesiredCapabilities capability = DesiredCapabilities.chrome();
        capability.setBrowserName("chrome");
        capability.setCapability("ignoreZoomSetting", true);
        capability.setPlatform(Platform.MAC);
        capability.setVersion("ANY");
        capability.setCapability("nativeEvents", false);
        driver = new RemoteWebDriver(new URL(CHROMENODEURL), capability);
    } else if ("Chrome".equals(browser) && "WINDOWS".equals(operatingSystem)) {
        DesiredCapabilities capability = DesiredCapabilities.chrome();
        capability.setBrowserName("chrome");
        capability.setCapability("ignoreZoomSetting", true);
        capability.setPlatform(Platform.WINDOWS);
        capability.setVersion("ANY");
        capability.setCapability("nativeEvents", false);
        driver = new RemoteWebDriver(new URL(CHROMENODEURL), capability);
    } else if ("IE".equals(browser) && "VISTA".equals(operatingSystem)) {
        DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
        capability.setBrowserName("internet explorer");
        capability.setCapability("ignoreZoomSetting", true);
        capability.setPlatform(Platform.VISTA);
        capability.setVersion("ANY");
        capability.setCapability("nativeEvents", false);
        capability.setCapability("name", "Remote File Upload using Selenium 2's FileDetectors");
        driver = new RemoteWebDriver(new URL(IENODEURL), capability);
    } else if ("IE".equals(browser) && "WINDOWS".equals(operatingSystem)) {
        DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
        capability.setBrowserName("internet explorer");
        capability.setCapability("ignoreZoomSetting", true);
        capability.setPlatform(Platform.WINDOWS);
        capability.setVersion("ANY");
        capability.setCapability("nativeEvents", false);
        driver = new RemoteWebDriver(new URL(IENODEURL), capability);
    } else if ("Safari".equals(browser) && "MAC".equals(operatingSystem)) {
        DesiredCapabilities capability = DesiredCapabilities.safari();
        capability.setBrowserName("safari");
        capability.setCapability("ignoreZoomSetting", true);
        capability.setPlatform(Platform.MAC);
        capability.setVersion("ANY");
        capability.setCapability("nativeEvents", false);
        driver = new RemoteWebDriver(new URL(IENODEURL), capability);
    }
    return driver;
}

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 www  .  j a  v a2 s . c o  m
        capabilities.setPlatform(Platform.ANY);
    }

    return capabilities;
}

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());
                }//from  w  w  w  .jav a 2 s  .  co  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 o  m
        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.qe4j.web.OpenWebDriver.java

License:Open Source License

/**
 * Converts the property definition of the platform to the Selenium enum
 * representation of it. Throws exception if the platform is not supported
 * by SauceLabs (current remote execution environment).
 *
 * @param platformProperty/*from w  ww. j  a  v a 2 s.  com*/
 * @return Selenium platform enum
 */
public static Platform lookupPlatform(String platformProperty) {
    String platform = platformProperty.toLowerCase();
    if (platform.equals("xp")) {
        return Platform.XP;
    } else if (platform.equals("vista")) {
        return Platform.VISTA;
    } else if (platform.equals("linux")) {
        return Platform.LINUX;
    } else if (platform.equals("windows")) {
        return Platform.WINDOWS;
    } else if (platform.equals("mac")) {
        return Platform.MAC;
    } else {
        throw new IllegalArgumentException(
                "platform property " + platformProperty + " is not currently supported for remote web driver");
    }
}

From source file:org.qe4j.web.OpenWebDriverTest.java

License:Open Source License

@Test
public void lookupPlatform() {
    Assert.assertEquals(OpenWebDriver.lookupPlatform("Xp"), Platform.XP, "xp platform");
    Assert.assertEquals(OpenWebDriver.lookupPlatform("VISTA"), Platform.VISTA, "vista/win7 platform");
    Assert.assertEquals(OpenWebDriver.lookupPlatform("linUX"), Platform.LINUX, "linux platform");
}

From source file:pt.fccn.saw.selenium.WebDriverTestBase.java

License:Open Source License

/**
 * Gets a suitable Platform object given a OS/Platform string..
 *
 * @param platformString The given string for the OS/Platform to use
 * @return The Platform object that represent the requested OS/Platform
 *//* w ww  .  j a  v  a  2s  .  c o m*/
private static Platform selectPlatform(String platformString) {
    Platform platform = null;

    if (platformString.contains("Windows")) {
        if (platformString.contains("2008")) {
            platform = Platform.VISTA;
        } else {
            platform = Platform.XP;
        }
    } else if (platformString.toLowerCase().equals("linux")) {
        platform = Platform.LINUX;
    } else {
        System.err.println("Cannot find a suitable platform/OS for [" + platformString + "]");
    }
    return platform;
}