本文整理匯總了Java中org.openqa.selenium.Platform.valueOf方法的典型用法代碼示例。如果您正苦於以下問題:Java Platform.valueOf方法的具體用法?Java Platform.valueOf怎麽用?Java Platform.valueOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openqa.selenium.Platform
的用法示例。
在下文中一共展示了Platform.valueOf方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getValue
import org.openqa.selenium.Platform; //導入方法依賴的package包/類
private Object getValue( String clazz, String value )
{
Object rtn = null;
switch ( clazz )
{
case "BOOLEAN":
rtn = Boolean.parseBoolean( value );
break;
case "OBJECT":
rtn = value;
break;
case "STRING":
rtn = value;
break;
case "PLATFORM":
rtn = ((value != null) ? Platform.valueOf( value.toUpperCase() ) : null );
break;
}
return rtn;
}
示例2: buildDesiredCapabilities
import org.openqa.selenium.Platform; //導入方法依賴的package包/類
/**
* Here you can add your capabilities you want to use.
*
* @see https://code.google.com/p/chromedriver/wiki/CapabilitiesAndSwitches#List_of_recognized_capabilities
*/
protected void buildDesiredCapabilities() {
DesiredCapabilities capabilities = createDesiredCapabilitiesForChrome();
// get Platform from environment
String platformString = System.getenv("PLATFORM");
if (platformString == null) {
platformString = Platform.WINDOWS.toString();
}
Platform platform = Platform.valueOf(platformString);
capabilities.setCapability("platform", platform);
// set browser version
String versionString = System.getenv("VERSION");
if (versionString != null) {
capabilities.setVersion("38");
}
// if chrome options are not build yet, we have to handle it
if (chromeOptions == null) {
buildChromeOptions();
}
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
this.desiredCapabilities = capabilities;
}
示例3: getPlatform
import org.openqa.selenium.Platform; //導入方法依賴的package包/類
private static Platform getPlatform(TestSlot slot) {
Object o = slot.getCapabilities().get(CapabilityType.PLATFORM);
if (o == null) {
return Platform.ANY;
} else {
if (o instanceof String) {
return Platform.valueOf((String) o);
} else if (o instanceof Platform) {
return (Platform) o;
} else {
throw new GridException("Cannot cast " + o + " to org.openqa.selenium.Platform");
}
}
}
示例4: extractPlatform
import org.openqa.selenium.Platform; //導入方法依賴的package包/類
/**
* Resolves a platform capability to a Platform instance.
*
* Taken from DefaultCapabilityMatcher with small modifications.
*
* @param o Object to resolve to a Platform
*
* @return Resolved Platform instance or <code>null</code>.
*/
Platform extractPlatform(Object o) {
if (o == null) {
return null;
}
if (o instanceof Platform) {
return (Platform) o;
} else if (o instanceof String) {
String name = o.toString();
try {
return Platform.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
// no exact match, continue to look for a partial match
}
for (Platform os : Platform.values()) {
for (String matcher : os.getPartOfOsName()) {
if ("".equals(matcher))
continue;
if (name.equalsIgnoreCase(matcher)) {
return os;
}
}
}
return null;
} else {
return null;
}
}
示例5: getGridPlatform
import org.openqa.selenium.Platform; //導入方法依賴的package包/類
/**
* @return the {@link Platform} specified in the property {@value #PROP_GRID_PLATFORM};
* null, if not defined
*/
public static Platform getGridPlatform() {
String value = getOptionalProperty(PROP_GRID_PLATFORM);
return (value == null) ? null : Platform.valueOf(value.toUpperCase());
}
示例6: getPlatformType
import org.openqa.selenium.Platform; //導入方法依賴的package包/類
public Platform getPlatformType() {
return Platform.valueOf(getPlatform().toUpperCase());
}
示例7: SeleniumManager
import org.openqa.selenium.Platform; //導入方法依賴的package包/類
/**
* {@link SeleniumManager} constructor managed by spring
*
* @param defaultDomain domain the whole selenium related SenBot will work from
* @param seleniumHubIP if running on a grid this is the hub ip to be used
* @param target The target environements to run the selenium tests on
* @param defaultWindowWidth browser window width to start the browser with
* @param defaultWindowHeight browser window height to start the browser with
* @param aTimeout implicit timeout to be used by selenium when performing a dom lookup or page refresh
* @throws IOException
*/
public SeleniumManager(
String defaultDomain,
String seleniumHubIP,
String target,
int defaultWindowWidth,
int defaultWindowHeight,
int aTimeout,
String implicitTimeout,
String webdriverCreationHookClassName)
throws IOException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
if(!StringUtils.isBlank(webdriverCreationHookClassName)) {
Constructor<?> constructor = Class.forName(webdriverCreationHookClassName).getConstructor();
webDriverCreationHook = (WebDriverCreationHook) constructor.newInstance();
}
if(defaultDomain != null) {
if(defaultDomain.toLowerCase().startsWith("http")) {
this.defaultDomain = defaultDomain;
}
else {
this.defaultDomain = "http://" + defaultDomain;
}
}
this.defaultWindowWidth = defaultWindowWidth;
this.defaultWindowHeight = defaultWindowHeight;
this.timeout = aTimeout;
if (!StringUtils.isBlank(implicitTimeout)) {
this.implicitTimeout = Integer.parseInt(implicitTimeout);
}
this.seleniumHub = (StringUtils.isBlank(seleniumHubIP)) ? null : new URL(seleniumHubIP);
if (StringUtils.isBlank(target)) {
throw new IllegalArgumentException("The selenium target environment property cannot be blank. Refer to senbot-runner.properties");
} else {
for (String ii : target.split(";")) {
String[] parts = ii.split(",");
String browserVersion = parts.length > 1 ? parts[1].trim() : "ANY";
Platform platform = Platform.valueOf(parts.length > 2 ? parts[2].trim() : "ANY");
String locale = parts.length > 3 ? parts[3].trim() : null;
TestEnvironment testEnvironment = new TestEnvironment(parts[0].trim(),
browserVersion,
platform,
locale);
seleniumTestEnvironments.add(testEnvironment);
}
}
}
示例8: readPlatform
import org.openqa.selenium.Platform; //導入方法依賴的package包/類
private static Platform readPlatform(String platformText) {
if (platformText == null) {
return null;
}
else return Platform.valueOf(platformText.toUpperCase());
}
示例9: connectToDriverForVersionOnAt
import org.openqa.selenium.Platform; //導入方法依賴的package包/類
/**
* Connects SeleniumHelper to a remote web driver.
* @param browser name of browser to connect to.
* @param version version of browser.
* @param platformName platform browser must run on.
* @param url url to connect to browser.
* @return true.
* @throws MalformedURLException if supplied url can not be transformed to URL.
*/
public boolean connectToDriverForVersionOnAt(String browser, String version, String platformName, String url)
throws MalformedURLException {
Platform platform = Platform.valueOf(platformName);
DesiredCapabilities desiredCapabilities = new DesiredCapabilities(browser, version, platform);
desiredCapabilities.setVersion(version);
return createAndSetRemoteDriver(url, desiredCapabilities);
}