Example usage for org.openqa.selenium.remote CapabilityType VERSION

List of usage examples for org.openqa.selenium.remote CapabilityType VERSION

Introduction

In this page you can find the example usage for org.openqa.selenium.remote CapabilityType VERSION.

Prototype

String VERSION

To view the source code for org.openqa.selenium.remote CapabilityType VERSION.

Click Source Link

Usage

From source file:com.atlassian.selenium.browsers.firefox.DisplayAwareFirefoxLauncher.java

License:Apache License

public DisplayAwareFirefoxLauncher(Capabilities browserOptions, RemoteControlConfiguration configuration,
        String sessionId, String browserLaunchLocation) throws InvalidBrowserExecutableException {
    String browserName = BrowserType.FIREFOX;
    BrowserLocator locator = new CombinedFirefoxLocator();
    String version = (String) browserOptions.getCapability(CapabilityType.VERSION);
    if ("2".equals(version)) {
        browserName = BrowserType.FIREFOX_2;
        locator = new Firefox2Locator();
    }//from  ww w .j  ava2s.  c o  m
    if ("3".equals(version)) {
        browserName = BrowserType.FIREFOX_3;
        locator = new Firefox3Locator();
    }
    String mode = (String) browserOptions.getCapability("mode");
    if (mode == null) {
        mode = "chrome";
    }
    if ("default".equals(mode)) {
        mode = "chrome";
    }

    BrowserInstallation installation = ApplicationRegistry.instance().browserInstallationCache()
            .locateBrowserInstallation(browserName, browserLaunchLocation, locator);

    if (installation == null) {
        throw new InvalidBrowserExecutableException("The specified path to the browser executable is invalid.");
    }

    if ("chrome".equals(mode)) {
        realLauncher = new DisplayAwareFirefoxChromeLauncher(browserOptions, configuration, sessionId,
                installation);
        return;
    }

    boolean proxyInjectionMode = browserOptions.is("proxyInjectionMode") || "proxyInjection".equals(mode);

    // You can't just individually configure a browser for PI mode; it's a server-level
    // configuration parameter
    boolean globalProxyInjectionMode = configuration.getProxyInjectionModeArg();
    if (proxyInjectionMode && !globalProxyInjectionMode) {
        if (proxyInjectionMode) {
            throw new RuntimeException(
                    "You requested proxy injection mode, but this server wasn't configured with -proxyInjectionMode on the command line");
        }
    }

    // if user didn't request PI, but the server is configured that way, just switch up to PI
    proxyInjectionMode = globalProxyInjectionMode;
    if (proxyInjectionMode) {
        realLauncher = new ProxyInjectionFirefoxCustomProfileLauncher(browserOptions, configuration, sessionId,
                installation);
        return;
    }

    // the mode isn't "chrome" or "proxyInjection"; at this point it had better be
    // CapabilityType.PROXY
    if (!CapabilityType.PROXY.equals(mode)) {
        throw new RuntimeException("Unrecognized browser mode: " + mode);
    }

    realLauncher = new FirefoxCustomProfileLauncher(browserOptions, configuration, sessionId, installation);

}

From source file:com.ecofactor.qa.automation.platform.ops.impl.AbstractDriverOperations.java

License:Open Source License

/**
 * Sets the hub capabilities./*w w w  . j  a  v  a  2  s  .com*/
 * @param capabilities the new hub capabilities
 */
protected void setHubCapabilities(final DesiredCapabilities capabilities) {

    capabilities.setCapability(CapabilityType.BROWSER_NAME, getDeviceName());
    if (hasPlatformParam()) {
        capabilities.setCapability(CapabilityType.PLATFORM, getPlatformName());
    }
    if (hasVersionParam()) {
        capabilities.setCapability(CapabilityType.VERSION, getVersion());
    }
}

From source file:com.ecofactor.qa.automation.platform.ops.impl.IOSOperations.java

License:Open Source License

/**
 * Creates the device driver.//from   ww w . j a  v a 2 s. com
 * @return the web driver
 * @throws DeviceException the device exception
 * @see com.ecofactor.qa.automation.mobile.ops.impl.AbstractMobileOperations#createDeviceDriver()
 */
@Override
protected WebDriver createDeviceDriver() throws DeviceException {

    WebDriver driver = null;
    if (!hasErrors) {
        try {
            final File classpathRoot = new File(System.getProperty("user.dir"));
            final File app = new File(classpathRoot, "/EcoFactor_iOS/EcoFactorNew.zip");
            setLogString("Application Path: " + app.getPath(), true);
            final DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("device", "iphone");
            capabilities.setCapability(CapabilityType.BROWSER_NAME, JenkinsParamUtil.getDeviceName());
            capabilities.setCapability(CapabilityType.VERSION, "7.0");
            capabilities.setCapability(CapabilityType.PLATFORM, SystemUtil.getOSType());
            capabilities.setCapability("cleanSession", true);
            capabilities.setCapability("app", app.getAbsolutePath());
            capabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
            driver = new SwipeableWebDriver(new URL(getAppiumHostUrl()), capabilities);
        } catch (Exception ex) {
            if (ex.getCause() instanceof HttpHostConnectException) {
                setErrorMsg("Appium not started");
                setLogString(errorMsg, true);
                hasErrors = true;
                throw new DeviceException("\033[41;1m" + getErrorMsg());
            }
            setLogString("\033[41;1mERROR in initialze (" + ex.getMessage() + ")", true);
            throw new DeviceException("ERROR in initialze (" + ex.getMessage() + ")");
        }
    }
    return driver;
}

From source file:com.ecofactor.qa.automation.platform.util.SeleniumDriverUtil.java

License:Open Source License

/**
 * Sets the hub capabilities./*from  w w w  .jav a2  s . c  o  m*/
 * @param capabilities the new hub capabilities
 */
private static void setHubCapabilities(final DesiredCapabilities capabilities) {

    if (hasPlatformParam()) {
        capabilities.setCapability(CapabilityType.PLATFORM, getPlatformName());
    }
    if (hasVersionParam()) {
        capabilities.setCapability(CapabilityType.VERSION, getVersion());
    }
}

From source file:com.expedia.lux.accountsettingstest.core.CreateWebDriverHelper.java

License:Open Source License

/**
 * Create webdriver entry//w w  w.  j a  v  a 2 s .c  o  m
 * 
 * @param testName
 * @param browserType
 *            1 is chrome, 2 is firefox, 0 is internet explorer, 3 is safari
 * @param logging
 * @return
 */
public static WebDriver createWebDriver(String testName, String testBrowser) {
    WebDriver driver = null;
    String isCloud = String.valueOf(isRemoteTest);

    if (!isRemoteTest) {
        DesiredCapabilities capabillities = new DesiredCapabilities();
        capabillities.setCapability(CapabilityType.SUPPORTS_WEB_STORAGE, false);
        switch (testBrowser.toUpperCase()) {
        case "IE":
            // Need set iedriver.exe file path
            System.setProperty("webdriver.ie.driver", ieDriverPath);
            driver = new InternetExplorerDriver(capabillities);
            break;
        case "FF":
            // TODO: Not stable
            capabillities.setCapability(FirefoxDriver.BINARY, new FirefoxBinary(new File(firefoxPath)));
            FirefoxProfile profile = new FirefoxProfile();
            profile.setAcceptUntrustedCertificates(true);
            capabillities.setCapability(FirefoxDriver.PROFILE, profile);
            driver = new FirefoxDriver(capabillities);
            break;
        case "SF":
            // TODO: No one's machine has safari installed in SZ
            driver = new SafariDriver(capabillities);
            break;
        default:
            // Need set the chromedriver.exe file path.
            System.setProperty("webdriver.chrome.driver", chromeDriverPath);
            driver = new ChromeDriver(capabillities);
            break;
        }
    } else {
        DesiredCapabilities capabillities;
        switch (testBrowser.toUpperCase()) {
        case "IE9":
            capabillities = DesiredCapabilities.internetExplorer();
            capabillities.setCapability(CapabilityType.VERSION, "9");
            break;
        case "FF":
            capabillities = DesiredCapabilities.firefox();
            break;
        case "SF":
            capabillities = DesiredCapabilities.safari();
            capabillities.setCapability("platform", "OS X 10.6");
            capabillities.setCapability("version", "5");
            capabillities.setCapability("disable-popup-handler", true);
            break;
        case "IE7":
            capabillities = DesiredCapabilities.internetExplorer();
            capabillities.setCapability(CapabilityType.VERSION, "7");
            break;
        case "IE8":
            capabillities = DesiredCapabilities.internetExplorer();
            capabillities.setCapability(CapabilityType.VERSION, "8");
            break;
        case "IE10":
            capabillities = DesiredCapabilities.internetExplorer();
            capabillities.setCapability(CapabilityType.VERSION, "10");
            break;
        case "IE11":
            capabillities = DesiredCapabilities.internetExplorer();
            capabillities.setCapability("version", "11");
            break;
        case "OP":
            capabillities = DesiredCapabilities.opera();
            capabillities.setCapability("version", "12");
            break;
        //Note: may not support HTTPS via sauceConnect with mobile platform yet
        case "IOS":
            capabillities = DesiredCapabilities.iphone();
            capabillities.setCapability("version", "6.1");
            capabillities.setCapability("platform", "OS X 10.8");
            capabillities.setCapability("device-orientation", "portrait");
            capabillities.setCapability("disable-popup-handler", true);
            break;
        case "AND":
            capabillities = DesiredCapabilities.android();
            capabillities.setCapability("version", "4.0");
            capabillities.setCapability("platform", "Linux");
            capabillities.setCapability("device-type", "tablet");
            capabillities.setCapability("device-orientation", "portrait");
            break;
        case "SAUCE":
            return createWebDriverSaucelab(testName + " (SauceLabs)");
        default:
            capabillities = DesiredCapabilities.chrome();
            capabillities.setBrowserName("chrome");
            break;
        }

        try {
            driver = new RemoteWebDriver(new URL("http://10.208.52.16:5555/wd/hub"), capabillities);
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    fillBrowserName(testBrowser, isCloud);
    return driver;
}

From source file:com.rmn.qa.AutomationRunRequest.java

License:Open Source License

/**
 * Generates a AutomationRunRequest object from the capabilities passed in
 * @param capabilities/*from  w w w. ja  v a 2s.co  m*/
 * @return
 */
public static AutomationRunRequest requestFromCapabilities(Map<String, Object> capabilities) {
    String capabilityBrowser = (String) capabilities.get(CapabilityType.BROWSER_NAME);
    String capabilityBrowserVersion = null;
    if (capabilities.containsKey(CapabilityType.VERSION)) {
        capabilityBrowserVersion = (String) capabilities.get(CapabilityType.VERSION);
    }
    Object platform = capabilities.get(CapabilityType.PLATFORM);
    Platform capabilityPlatform = AutomationUtils.getPlatformFromObject(platform);
    return new AutomationRunRequest(null, null, capabilityBrowser, capabilityBrowserVersion,
            capabilityPlatform);
}

From source file:com.rmn.qa.AutomationRunRequest.java

License:Open Source License

/**
 * Returns true if this run request matches the capabilities passed in.  Includes browser, browser version, and OS
 * @param capabilities/*from ww  w  .jav a2s  .  c om*/
 * @return
 */
public boolean matchesCapabilities(Map<String, Object> capabilities) {
    String capabilityBrowser = (String) capabilities.get(CapabilityType.BROWSER_NAME);
    String capabilityBrowserVersion = (String) capabilities.get(CapabilityType.VERSION);
    Object capabilityPlatformObject = capabilities.get(CapabilityType.PLATFORM);
    Platform capabilityPlatform = AutomationUtils.getPlatformFromObject(capabilityPlatformObject);
    if (!AutomationUtils.lowerCaseMatch(browser, capabilityBrowser)) {
        return false;
    }
    if (browserVersion != null && !AutomationUtils.lowerCaseMatch(browserVersion, capabilityBrowserVersion)) {
        return false;
    }
    if (platform != null
            && !AutomationUtils.firstPlatformCanBeFulfilledBySecondPlatform(platform, capabilityPlatform)) {
        return false;
    }
    return true;
}

From source file:com.rmn.qa.AutomationRunRequestTest.java

License:Open Source License

@Test
// Tests that two run request objects match each other
public void testMatchesCapabilities() {
    String uuid = "testUuid";
    String browser = "firefox";
    String browserVersion = "20";
    Platform os = Platform.LINUX;//from w ww  .ja  va2 s .com
    Map<String, Object> map = Maps.newHashMap();
    map.put(CapabilityType.BROWSER_NAME, browser);
    map.put(CapabilityType.VERSION, browserVersion);
    map.put(CapabilityType.PLATFORM, os);
    AutomationRunRequest first = new AutomationRunRequest(uuid, null, browser, browserVersion, os);
    Assert.assertTrue("Capabilities should match", first.matchesCapabilities(map));
}

From source file:com.rmn.qa.AutomationRunRequestTest.java

License:Open Source License

@Test
// Tests that two run request objects dont match each other due to incorrect browser
public void testMatchesCapabilitiesBadBrowser() {
    String uuid = "testUuid";
    String browser = "firefox";
    String browserVersion = "20";
    Platform os = Platform.LINUX;/*from w  w  w. j  a v  a 2s .c  om*/
    Map<String, Object> map = Maps.newHashMap();
    map.put(CapabilityType.BROWSER_NAME, browser);
    map.put(CapabilityType.VERSION, browserVersion);
    map.put(CapabilityType.PLATFORM, os);
    AutomationRunRequest first = new AutomationRunRequest(uuid, null, "badBrowser", browserVersion, os);
    Assert.assertFalse("Capabilities should match", first.matchesCapabilities(map));
}

From source file:com.rmn.qa.AutomationRunRequestTest.java

License:Open Source License

@Test
// Tests that two run request objects dont match each other due to incorrect browser version
public void testMatchesCapabilitiesBadVersion() {
    String uuid = "testUuid";
    String browser = "firefox";
    String browserVersion = "20";
    Platform os = Platform.LINUX;/*from www  .j  a  v a  2s  .c o m*/
    Map<String, Object> map = Maps.newHashMap();
    map.put(CapabilityType.BROWSER_NAME, browser);
    map.put(CapabilityType.VERSION, browserVersion);
    map.put(CapabilityType.PLATFORM, os);
    AutomationRunRequest first = new AutomationRunRequest(uuid, null, browser, "123", os);
    Assert.assertFalse("Capabilities should match", first.matchesCapabilities(map));
}