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:com.seleniumtests.core.SeleniumTestsContext.java

License:Apache License

/**
 * From platform name, in case of Desktop platform, do nothing and in case of mobile, extract OS version from name
 * as platformName will be 'Android 5.0' for example
 *
 * @throws ConfigurationException    in mobile, if version is not present
 *//*w  w w.  ja v a 2 s  . c o  m*/
private void updatePlatformVersion() {
    try {
        Platform currentPlatform = Platform.fromString(getPlatform());
        if (currentPlatform.is(Platform.WINDOWS) || currentPlatform.is(Platform.MAC)
                || currentPlatform.is(Platform.UNIX)
                || currentPlatform.is(Platform.ANY) && getRunMode() == DriverMode.GRID) {
            return;

        } else {
            throw new WebDriverException("");
        }
    } catch (WebDriverException e) {
        if (getPlatform().toLowerCase().startsWith("android")
                || getPlatform().toLowerCase().startsWith("ios")) {
            String[] pfVersion = getPlatform().split(" ", 2);
            try {
                setPlatform(pfVersion[0]);
                setMobilePlatformVersion(pfVersion[1]);
                return;
            } catch (IndexOutOfBoundsException x) {
                setMobilePlatformVersion(null);
                logger.warn(
                        "For mobile platform, platform name should contain version. Ex: 'Android 5.0' or 'iOS 9.1'. Else, first found device is used");
            }

        } else {
            throw new ConfigurationException(
                    String.format("Platform %s has not been recognized as a valid platform", getPlatform()));
        }
    }
}

From source file:com.seleniumtests.ut.browserfactory.mobile.TestInstrumentsWrapper.java

License:Apache License

@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testNotOnMac() {
    PowerMockito.mockStatic(OSUtility.class);
    when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.WINDOWS);

    new InstrumentsWrapper();
}

From source file:com.seleniumtests.ut.browserfactory.TestBrowserInfo.java

License:Apache License

/**
 * Check that we get the driver list if driver artifact is installed for the right OS
 * @throws Exception /*from w  w w  .j a v a 2  s . c  o  m*/
 */
@Test(groups = { "ut" })
public void testGetDriverFilesWithInstalledArtifact() throws Exception {
    PowerMockito.mockStatic(OSUtility.class);
    when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.WINDOWS);

    String[] driversFiles = new String[] { "windows/chromedriver_2.20_chrome-55-57_android-6.0.exe",
            "windows/chromedriver_2.29_chrome-56-58_android-7.0.exe",
            "windows/chromedriver_2.31_chrome-58-60.exe" };

    BrowserInfo bInfo = PowerMockito.spy(new BrowserInfo(BrowserType.CHROME, "55.0", null));
    PowerMockito.when(bInfo, "getDriverListFromJarResources", "driver-list-windows.txt")
            .thenReturn(driversFiles);

    Assert.assertEquals(bInfo.getDriverFiles().size(), 3);
}

From source file:com.seleniumtests.ut.browserfactory.TestBrowserInfo.java

License:Apache License

/**
 * If artifact is not installed, getDriverListFromJarResources raises NullPointerException
 * @throws Exception/*from  ww w. j  av  a 2s.  c o m*/
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testGetDriverFilesWithNotInstalledArtifact() throws Exception {
    PowerMockito.mockStatic(OSUtility.class);
    when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.WINDOWS);

    BrowserInfo bInfo = PowerMockito.spy(new BrowserInfo(BrowserType.CHROME, "55.0", null));
    PowerMockito.when(bInfo, "getDriverListFromJarResources", "driver-list-windows.txt")
            .thenThrow(NullPointerException.class);

    Assert.assertEquals(bInfo.getDriverFiles().size(), 3);
}

From source file:com.seleniumtests.ut.browserfactory.TestChromeCapabilityFactory.java

License:Apache License

@Test(groups = { "ut" })
public void testCreateDefaultCapabilitiesWithPlatform() {

    Mockito.when(config.isEnableJavascript()).thenReturn(true);
    Mockito.when(config.getProxy()).thenReturn(proxyConfig);
    Mockito.when(config.getWebPlatform()).thenReturn(Platform.WINDOWS);

    MutableCapabilities capa = new ChromeCapabilitiesFactory(config).createCapabilities();

    Assert.assertEquals(capa.getPlatform(), Platform.WINDOWS);

}

From source file:com.seleniumtests.ut.browserfactory.TestDesktopCommonCapabilityFactory.java

License:Apache License

@Test(groups = { "ut" })
public void testCreateDefaultCapabilitiesWithPlatform() {

    when(config.isEnableJavascript()).thenReturn(true);
    when(config.getProxy()).thenReturn(proxyConfig);
    when(config.getWebPlatform()).thenReturn(Platform.WINDOWS);

    MutableCapabilities capa = new HtmlUnitCapabilitiesFactory(config).createCapabilities();

    Assert.assertEquals(capa.getPlatform(), Platform.WINDOWS);

}

From source file:com.seleniumtests.ut.browserfactory.TestEdgeCapabilityFactory.java

License:Apache License

@BeforeMethod(groups = { "ut" })
public void init() {
    PowerMockito.mockStatic(System.class);
    PowerMockito.when(System.getProperty(anyString())).thenCallRealMethod();
    PowerMockito.when(System.setProperty(anyString(), anyString())).thenCallRealMethod();
    PowerMockito.when(System.clearProperty(anyString())).thenCallRealMethod();
    PowerMockito.when(System.getProperty("os.name")).thenReturn("Windows 10");

    Map<BrowserType, List<BrowserInfo>> browserInfos = new HashMap<>();
    browserInfos.put(BrowserType.EDGE, Arrays.asList(new BrowserInfo(BrowserType.EDGE, "14393", "", false)));

    PowerMockito.mockStatic(OSUtility.class);
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion()).thenReturn(browserInfos);
    PowerMockito.when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.WINDOWS);

    PowerMockito.mockStatic(OSUtilityFactory.class);
    PowerMockito.when(OSUtilityFactory.getInstance()).thenReturn(osUtility);

    Mockito.when(config.getDebug()).thenReturn(Arrays.asList(DebugMode.NONE));
    Mockito.when(config.getPageLoadStrategy()).thenReturn(PageLoadStrategy.NORMAL);

    when(osUtility.getProgramExtension()).thenReturn(".exe");
}

From source file:com.seleniumtests.ut.browserfactory.TestEdgeCapabilityFactory.java

License:Apache License

@Test(groups = { "ut" })
public void testCreateDefaultCapabilitiesWithPlatform() {

    Mockito.when(config.isEnableJavascript()).thenReturn(true);
    Mockito.when(config.getProxy()).thenReturn(proxyConfig);
    Mockito.when(config.getWebPlatform()).thenReturn(Platform.WINDOWS);

    MutableCapabilities capa = new EdgeCapabilitiesFactory(config).createCapabilities();

    Assert.assertEquals(capa.getPlatform(), Platform.WINDOWS);

}

From source file:com.seleniumtests.ut.browserfactory.TestFirefoxCapabilitiesFactory.java

License:Apache License

@Test(groups = { "ut" })
public void testCreateDefaultCapabilitiesWithPlatform() {

    Mockito.when(config.isEnableJavascript()).thenReturn(true);
    Mockito.when(config.getProxy()).thenReturn(proxyConfig);
    Mockito.when(config.getWebPlatform()).thenReturn(Platform.WINDOWS);

    MutableCapabilities capa = new FirefoxCapabilitiesFactory(config).createCapabilities();

    Assert.assertEquals(capa.getPlatform(), Platform.WINDOWS);

}

From source file:com.seleniumtests.ut.browserfactory.TestIECapabilityFactory.java

License:Apache License

@BeforeMethod(groups = { "ut" })
public void init() {
    PowerMockito.mockStatic(System.class);
    PowerMockito.when(System.getProperty(anyString())).thenCallRealMethod();
    PowerMockito.when(System.setProperty(anyString(), anyString())).thenCallRealMethod();
    PowerMockito.when(System.clearProperty(anyString())).thenCallRealMethod();
    PowerMockito.when(System.getProperty("os.name")).thenReturn("Windows 10");

    Map<BrowserType, List<BrowserInfo>> browserInfos = new HashMap<>();
    browserInfos.put(BrowserType.INTERNET_EXPLORER,
            Arrays.asList(new BrowserInfo(BrowserType.INTERNET_EXPLORER, "11", "", false)));

    PowerMockito.mockStatic(OSUtility.class);
    PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion()).thenReturn(browserInfos);
    PowerMockito.when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.WINDOWS);

    PowerMockito.mockStatic(OSUtilityFactory.class);
    PowerMockito.when(OSUtilityFactory.getInstance()).thenReturn(osUtility);

    when(osUtility.getProgramExtension()).thenReturn(".exe");

    when(config.getTestContext()).thenReturn(context);
    Mockito.when(config.getDebug()).thenReturn(Arrays.asList(DebugMode.NONE));

}