Java Code Examples for org.openqa.selenium.Platform#is()

The following examples show how to use org.openqa.selenium.Platform#is() . 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: PlatformMatcher.java    From selenium-api with MIT License 6 votes vote down vote up
@Override
public boolean matches(Object requested, Object provided) {
    Platform requestedPlatform = extractPlatform(requested);

    if (requestedPlatform != null) {
        Platform node = extractPlatform(provided);

        if (node == null) {
            return false;
        }
        if (!node.is(requestedPlatform)) {
            return false;
        }
    } else {
      LOGGER.warning(String.format("Unable to extract requested platform from '%s'.",requested));
    }

    return true;
}
 
Example 2
Source File: CommandLine.java    From selenium with Apache License 2.0 5 votes vote down vote up
/**
 * @return The platform specific env property name which contains the library path.
 */
public static String getLibraryPathPropertyName() {
  Platform current = Platform.getCurrent();

  if (current.is(WINDOWS)) {
    return "PATH";

  } else if (current.is(MAC)) {
    return "DYLD_LIBRARY_PATH";

  } else {
    return "LD_LIBRARY_PATH";
  }
}
 
Example 3
Source File: InternetExplorerDriver.java    From selenium with Apache License 2.0 5 votes vote down vote up
protected void assertOnWindows() {
  Platform current = Platform.getCurrent();
  if (!current.is(Platform.WINDOWS)) {
    throw new WebDriverException(
        String.format(
            "You appear to be running %s. The IE driver only runs on Windows.", current));
  }
}
 
Example 4
Source File: CapabilitiesComparator.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Override
public int score(Platform value) {
  if (!currentIsDesired || isNullOrAny(value)) {
    return 0;
  }

  return scoreAgainst.is(value) || value.is(scoreAgainst) ? 1 : -1;
}
 
Example 5
Source File: CapabilitiesComparator.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Override
public int score(Platform value) {
  if (isNullOrAny(value)) {
    return 0;
  }

  return value.is(scoreAgainst) || scoreAgainst.is(value) ? 1 : -1;
}
 
Example 6
Source File: CapabilitiesComparator.java    From selenium with Apache License 2.0 4 votes vote down vote up
private CurrentPlatformScorer(Platform currentPlatform, Platform desiredPlatform) {
  super(currentPlatform);
  currentIsDesired = !isNullOrAny(currentPlatform)
      && (currentPlatform.is(desiredPlatform) || desiredPlatform.is(currentPlatform));
}
 
Example 7
Source File: DefaultDriverFactory.java    From selenium with Apache License 2.0 4 votes vote down vote up
private boolean platformMatches(Platform current, Capabilities caps) {
  return caps.getPlatform() == null
         || caps.getPlatform() == ANY
         || current.is(caps.getPlatform());
}