Example usage for org.openqa.selenium Platform WIN8

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

Introduction

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

Prototype

Platform WIN8

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

Click Source Link

Document

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

Usage

From source file:com.galenframework.tests.parser.GalenPageTestParserTest.java

License:Apache License

@DataProvider
public Object[][] provideGoodSamples() {
    return new Object[][] {
            test("http://example.org 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumBrowserFactory())),

            test("selenium firefox http://example.org 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumBrowserFactory())),

            test("selenium chrome http://example.org 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumBrowserFactory(SeleniumBrowserFactory.CHROME))),

            test("selenium ie http://example.org 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumBrowserFactory(SeleniumBrowserFactory.IE))),

            test("selenium phantomjs http://example.org 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumBrowserFactory("phantomjs"))),

            test("selenium whatever_other_browser http://example.org 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumBrowserFactory("whatever_other_browser"))),

            test("Selenium Chrome http://example.org 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumBrowserFactory(SeleniumBrowserFactory.CHROME))),

            test("SELENIUM CHROME http://example.org 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumBrowserFactory(SeleniumBrowserFactory.CHROME))),

            test("selenium grid http://mygrid:8080/wd/hub --page http://example.org --size 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumGridBrowserFactory("http://mygrid:8080/wd/hub"))),

            test("selenium grid http://mygrid:8080/wd/hub --browser chrome --page http://example.org --size 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480).withBrowserFactory(
                            new SeleniumGridBrowserFactory("http://mygrid:8080/wd/hub").withBrowser("chrome"))),

            test("selenium grid http://mygrid:8080/wd/hub --browser chrome --version 21.1 --page http://example.org --size 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumGridBrowserFactory("http://mygrid:8080/wd/hub")
                                    .withBrowser("chrome").withBrowserVersion("21.1"))),

            test("selenium grid http://mygrid:8080/wd/hub --browser chrome --version 21.1 --platform XP --page http://example.org --size 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumGridBrowserFactory("http://mygrid:8080/wd/hub")
                                    .withBrowser("chrome").withBrowserVersion("21.1")
                                    .withPlatform(Platform.XP))),

            test("selenium grid http://mygrid:8080/wd/hub --browser chrome --version 21.1 --platform WIN8 --page http://example.org --size 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumGridBrowserFactory("http://mygrid:8080/wd/hub")
                                    .withBrowser("chrome").withBrowserVersion("21.1")
                                    .withPlatform(Platform.WIN8))),

            test("selenium grid http://mygrid:8080/wd/hub --dc.device-orientation portrait --dc.platform \"OS X 10.0\" --page http://example.org --size 640x480",
                    new GalenPageTest().withUrl("http://example.org").withSize(640, 480)
                            .withBrowserFactory(new SeleniumGridBrowserFactory("http://mygrid:8080/wd/hub")
                                    .withDesiredCapability("device-orientation", "portrait")
                                    .withDesiredCapability("platform", "OS X 10.0"))),

            test("jsfactory script.js http://example.com 640x480", new GalenPageTest().withBrowserFactory(
                    new JsBrowserFactory("script.js", new String[] { "http://example.com", "640x480" }))) };
}

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//from  w ww. ja v  a  2s. c om
 * @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: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 {// w  w w . ja  v a 2s .c  om
        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());
                }//  w  w w.  j  ava 2  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 w w w .  j a  v  a2s  . co 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();
}