Java Code Examples for org.openqa.selenium.Platform#valueOf()
The following examples show how to use
org.openqa.selenium.Platform#valueOf() .
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: SQLApplicationProvider.java From xframium-java with GNU General Public License v3.0 | 6 votes |
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; }
Example 2
Source File: BrowserSpecs.java From KITE with Apache License 2.0 | 5 votes |
/** * Instantiates a new browser specs. * * @param jsonObject the json object */ public BrowserSpecs(JsonObject jsonObject){ this(); // Mandatory this.version = jsonObject.getString("version", null); String platform = jsonObject.getString("platform", "localhost").toUpperCase(); // appium requires device name, but any is fine this.deviceName = jsonObject.getString("deviceName", "unknown"); this.browserName = jsonObject.getString("browserName", "Browser"); // if (this.deviceName.equals("unknown")) { // // will throw exception in case the client is not an app // this.browserName = jsonObject.getString("browserName"); // } else { // this.browserName = platform.toLowerCase().contains("android") ? "APK" : "IPA"; // } this.platformVersion = jsonObject.getString("platformVersion", null); if (platform.equalsIgnoreCase("localhost")) { platform = getSystemPlatform(); } this.platform = Platform.valueOf(platform); // Optional this.pathToBinary = jsonObject.getString("pathToBinary", this.pathToBinary); this.pathToDriver = jsonObject.getString("pathToDriver", this.pathToDriver); this.profile = jsonObject.getString("profile", ""); this.extension = jsonObject.getString("extension", ""); }
Example 3
Source File: PlatformMatcher.java From selenium-api with MIT License | 5 votes |
/** * 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; } }
Example 4
Source File: BrowserInstance.java From kurento-java with Apache License 2.0 | 4 votes |
public Platform getPlatformType() { return Platform.valueOf(getPlatform().toUpperCase()); }
Example 5
Source File: SeleniumManager.java From senbot with MIT License | 4 votes |
/** * {@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); } } }
Example 6
Source File: SeleniumDriverSetup.java From hsac-fitnesse-fixtures with Apache License 2.0 | 3 votes |
/** * 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); }