Example usage for org.openqa.selenium Platform WINDOWS

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

Introduction

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

Prototype

Platform WINDOWS

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

Click Source Link

Document

Never returned, but can be used to request a browser running on any version of Windows.

Usage

From source file:WebTestSelenium4.java

public void setUp() throws Exception {
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("version", "11");
    capabilities.setCapability("platform", Platform.WINDOWS);
    capabilities.setCapability("name", "Testing Selenium 2");
    try {/*  w  ww . ja  v  a 2 s . com*/
        this.driver = new RemoteWebDriver(new URL(URL), capabilities);
        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    } catch (Exception ex) {
        System.out.println("Driver problem");
    }
    this.driver.get("http://www.harvard.edu/");
}

From source file:RunSafariAcceptanceTests.java

License:Apache License

@BeforeClass
public static void setupSquashWebsiteUrl() {
    Platform current = Platform.getCurrent();
    Assert.assertTrue("Safari can be used only on MAC and Windows platforms",
            Platform.MAC.is(current) || Platform.WINDOWS.is(current));

    Properties p = new Properties(System.getProperties());
    p.setProperty("SquashWebsiteBaseUrl",
            "http://squashwebsite.s3-website-eu-west-1.amazonaws.com/?selectedDate=2016-01-11.html");
    // This will be read before each scenario to set up the webdriver
    p.setProperty("WebDriverType", "Safari");
    p.setProperty("WebDriverJavascriptEnabled", "true");
    System.setProperties(p);/*from w  w  w . ja va  2  s .co  m*/
}

From source file:WebTestSelenium3.java

public void setUp() throws Exception {
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("version", "11");
    capabilities.setCapability("platform", Platform.WINDOWS);
    capabilities.setCapability("name", "Testing Selenium 2");
    try {/*from   w ww  .  j  a va2  s  .  com*/
        this.driver = new RemoteWebDriver(new URL(URL), capabilities);
        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    } catch (Exception ex) {
        System.out.println("Driver problem");
    }
    this.driver.get("http://www.berkeley.edu/");
}

From source file:com.ceiwc.compugain.setup.TestBase.java

public WebDriver initializeDriver(String sbrowser, String sgrid) {
    WebDriver driver = null;//from   www  .j av  a2s  .c  om
    logger.info("Test Base Version is" + Configuration.getGrid());
    logger.info("Test Base Browser is" + sbrowser);
    sgrid = Configuration.getGrid();
    if (sgrid.equalsIgnoreCase("")) {
        sbrowser = Configuration.getAutomationBrowser();
        return driver = initializeDriver(sbrowser);
    } else if (!sgrid.equalsIgnoreCase("") && !sbrowser.equalsIgnoreCase("")) {
        logger.info("I am in Grid Intialization");
        DesiredCapabilities capabilities = new DesiredCapabilities();
        URL hubUrl = null;
        try {
            hubUrl = new URL("http://localhost:4444/wb/hub");
            if (sbrowser.equalsIgnoreCase("firefox")) {
                FirefoxProfile profile = new FirefoxProfile();
                profile.setPreference("browser.download.folderList", 2);
                capabilities.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
                capabilities.setPlatform(Platform.WINDOWS);
                driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
                //remoteWebDriver.setFileDetector(new LocalFileDetector());
            }
            if (sbrowser.equalsIgnoreCase("chrome")) {
                System.setProperty("webdriver.chrome.driver", getFilePath(CHROMEPATH));
                capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
                //capabilities.setVersion(sversion1);
                capabilities.setPlatform(Platform.WINDOWS);
                driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }
    return driver;

}

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//from w w  w .  j  a  v  a  2  s.com
 * @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:com.github.trask.sandbox.saucelabs.SauceLabsWebDriverProvider.java

License:Apache License

public WebDriver get(String testName) {
    logger.debug("get()");
    DesiredCapabilities capabilities = new DesiredCapabilities("firefox", "3.6.", Platform.WINDOWS);
    capabilities.setCapability("name", testName);
    URL url;//  w  w w.j av  a  2  s  .co  m
    try {
        url = new URL("http://" + sauceLabsCredentials.getUsername() + ":" + sauceLabsCredentials.getApiKey()
                + "@ondemand.saucelabs.com/wd/hub");
    } catch (MalformedURLException e) {
        throw new IllegalStateException(e);
    }
    return new RemoteWebDriver(url, capabilities);
}

From source file:com.htmlhifive.pitalium.core.io.FileNameFormatterTest.java

License:Apache License

/**
 * ?//from w ww.  j a  v a2 s .  co m
 */
@Test
public void testFormat_selector() throws Exception {
    PtlCapabilities capabilities = new PtlCapabilities(new HashMap<String, Object>());
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setBrowserName("firefox");
    capabilities.setVersion("38");

    PersistMetadata metadata = new PersistMetadata("testId", "testClass", "testMethod", "scId",
            new IndexDomSelector(SelectorType.TAG_NAME, "body", 1), null, capabilities);

    FileNameFormatter formatter = new FileNameFormatter(
            "{platformName}_{platformVersion}_{browserName}_{version}_{screenArea}.png");
    String result = formatter.format(metadata);
    assertThat(result, is("testMethod_scId_WINDOWS_firefox_38_TAG_NAME_body_[1].png"));
}

From source file:com.htmlhifive.pitalium.core.io.FileNameFormatterTest.java

License:Apache License

/**
 * ?//from  www . ja v a 2  s  .  c  o m
 */
@Test
public void testFormat_rectangle() throws Exception {
    PtlCapabilities capabilities = new PtlCapabilities(new HashMap<String, Object>());
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setBrowserName("firefox");
    capabilities.setVersion("38");

    PersistMetadata metadata = new PersistMetadata("testId", "testClass", "testMethod", "scId", null,
            new RectangleArea(0, 10, 100, 1000), capabilities);

    FileNameFormatter formatter = new FileNameFormatter(
            "{platformName}_{platformVersion}_{browserName}_{version}_{screenArea}.png");
    String result = formatter.format(metadata);
    assertThat(result, is("testMethod_scId_WINDOWS_firefox_38_rect_0_10_100_1000.png"));
}

From source file:com.htmlhifive.pitalium.core.io.FileNameFormatterTest.java

License:Apache License

/**
 * ?????????//w  w w.j  a v a 2 s  . co  m
 */
@Test
public void testFormat_escape() throws Exception {
    PtlCapabilities capabilities = new PtlCapabilities(new HashMap<String, Object>());
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setBrowserName("firefox");
    capabilities.setVersion("38");

    PersistMetadata metadata = new PersistMetadata("testId", "testClass", "testMethod", "scId",
            new IndexDomSelector(SelectorType.CSS_SELECTOR, "1\\\\2/3:4*5?6\"7<8>9|0", 1), null, capabilities);

    FileNameFormatter formatter = new FileNameFormatter(
            "{platformName}_{platformVersion}_{browserName}_{version}_{screenArea}.png");
    String result = formatter.format(metadata);
    assertThat(result, is("testMethod_scId_WINDOWS_firefox_38_CSS_SELECTOR_1-2-3-4-5-6-7-8-9-0_[1].png"));
}

From source file:com.htmlhifive.pitalium.image.model.PersistedScreenshotImageTest.java

License:Apache License

@Before
public void setUp() throws Exception {
    persister = new FilePersister(FilePersisterConfig.builder().resultDirectory(DIRECTORY_NAME).build());

    PtlCapabilities capabilities = new PtlCapabilities(new HashMap<String, Object>());
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setBrowserName("firefox");
    capabilities.setVersion("38");
    IndexDomSelector selector = new IndexDomSelector(SelectorType.ID, "main", 0);
    metadata = new PersistMetadata("testId", "testClass", "testMethod", "scId", selector, null, capabilities);
}