Java Code Examples for org.openqa.selenium.Platform#MAC

The following examples show how to use org.openqa.selenium.Platform#MAC . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SeleniumHelper.java    From hsac-fitnesse-fixtures with Apache License 2.0 5 votes vote down vote up
/**
 * @return whether current driver connects to browser on a Mac
 */
public boolean connectedToMac() {
    boolean isMac;
    WebDriver driver = driver();
    if (driver instanceof RemoteWebDriver) {
        RemoteWebDriver remoteWebDriver = (RemoteWebDriver) driver;
        Platform platform = remoteWebDriver.getCapabilities().getPlatform();
        isMac = Platform.MAC == platform || Platform.MAC == platform.family();
    } else {
        isMac = SystemUtils.IS_OS_MAC;
    }
    return isMac;
}
 
Example 2
Source File: PlatformMatcherTest.java    From selenium-api with MIT License 5 votes vote down vote up
@DataProvider
public Object[][] platforms() {
    return new Object[][]{
            {"win7", Platform.VISTA, true},
            {"win7", "windows 7", true},
            {"vista", Platform.VISTA, true},
            {"darwin", Platform.MAC, true},
            {Platform.ANY, Platform.LINUX, true},
            {"linux", Platform.LINUX, true},
            {"linux", Platform.UNIX, false},
            {null, Platform.XP, true},
    };
}
 
Example 3
Source File: DriverFactoryTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void testShouldRegisterCorrectDefaultsOnMac() {
  DefaultDriverFactory factory = new DefaultDriverFactory(Platform.MAC);

  assertTrue(canInstantiate(factory, CHROME));
  assertTrue(canInstantiate(factory, EDGE));
  assertTrue(canInstantiate(factory, FIREFOX));
  assertTrue(canInstantiate(factory, SAFARI));
  assertFalse(canInstantiate(factory, IE));
}
 
Example 4
Source File: PtlWebDriverFactory.java    From hifive-pitalium with Apache License 2.0 4 votes vote down vote up
/**
 * ブラウザに対応する{@link PtlWebDriverFactory}のインスタンスを取得します。
 *
 * @param capabilities Capability(ブラウザの情報を含む)
 * @return {@link PtlWebDriverFactory}のインスタンス
 */
public static PtlWebDriverFactory getInstance(PtlCapabilities capabilities) {
	PtlTestConfig config = PtlTestConfig.getInstance();
	EnvironmentConfig environmentConfig = config.getEnvironment();
	TestAppConfig testAppConfig = config.getTestAppConfig();

	String browserName = Strings.nullToEmpty(capabilities.getBrowserName()).toLowerCase(Locale.ENGLISH);

	// IE
	if ("internet explorer".equals(browserName)) {
		String version = Strings.nullToEmpty(capabilities.getVersion());
		if (version.startsWith("7")) {
			return new PtlInternetExplorer7DriverFactory(environmentConfig, testAppConfig, capabilities);
		}
		if (version.startsWith("8")) {
			return new PtlInternetExplorer8DriverFactory(environmentConfig, testAppConfig, capabilities);
		}

		return new PtlInternetExplorerDriverFactory(environmentConfig, testAppConfig, capabilities);
	}

	// Edge
	if ("microsoftedge".equals(browserName)) {
		return new PtlEdgeDriverFactory(environmentConfig, testAppConfig, capabilities);
	}

	// Android
	if (capabilities.getPlatform() == Platform.ANDROID) {
		// Selendroid (Android 2.3+)
		String automationName = (String) capabilities.getCapability("automationName");
		if (automationName != null && "selendroid".equalsIgnoreCase(automationName)) {
			return new PtlSelendroidDriverFactory(environmentConfig, testAppConfig, capabilities);
		}

		// Default (Android 4.2+)
		return new PtlAndroidDriverFactory(environmentConfig, testAppConfig, capabilities);
	}

	// Chrome
	if ("chrome".equals(browserName)) {
		return new PtlChromeWebDriverFactory(environmentConfig, testAppConfig, capabilities);
	}

	// Safari
	if ("safari".equals(browserName)) {
		// MacOSX
		if (capabilities.getPlatform() == Platform.MAC) {
			return new PtlSafariDriverFactory(environmentConfig, testAppConfig, capabilities);
		}

		String deviceName = capabilities.getDeviceName();
		if (Strings.isNullOrEmpty(deviceName)) {
			throw new TestRuntimeException("\"deviceName\" is required for iOS devices");
		}
		if (deviceName.contains("iPad")) {
			return new PtlIPadDriverFactory(environmentConfig, testAppConfig, capabilities);
		}
		if (deviceName.contains("iPhone")) {
			return new PtlIPhoneDriverFactory(environmentConfig, testAppConfig, capabilities);
		}

		throw new TestRuntimeException("Unknown deviceName \"" + deviceName + "\"");
	}

	// Other
	return new PtlFirefoxWebDriverFactory(environmentConfig, testAppConfig, capabilities);
}