下面列出了org.openqa.selenium.Platform#is ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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;
}
/**
* @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";
}
}
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));
}
}
@Override
public int score(Platform value) {
if (!currentIsDesired || isNullOrAny(value)) {
return 0;
}
return scoreAgainst.is(value) || value.is(scoreAgainst) ? 1 : -1;
}
@Override
public int score(Platform value) {
if (isNullOrAny(value)) {
return 0;
}
return value.is(scoreAgainst) || scoreAgainst.is(value) ? 1 : -1;
}
private CurrentPlatformScorer(Platform currentPlatform, Platform desiredPlatform) {
super(currentPlatform);
currentIsDesired = !isNullOrAny(currentPlatform)
&& (currentPlatform.is(desiredPlatform) || desiredPlatform.is(currentPlatform));
}
private boolean platformMatches(Platform current, Capabilities caps) {
return caps.getPlatform() == null
|| caps.getPlatform() == ANY
|| current.is(caps.getPlatform());
}