Java Code Examples for org.openqa.selenium.remote.DesiredCapabilities#setVersion()

The following examples show how to use org.openqa.selenium.remote.DesiredCapabilities#setVersion() . These examples are extracted from open source projects. 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 Project: packagedrone   File: TestSuite.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected static RemoteWebDriver createSauce ( final Platform os, final String browser, final String version ) throws MalformedURLException
{
    final DesiredCapabilities capabilities = new DesiredCapabilities ();
    capabilities.setBrowserName ( browser );
    if ( version != null )
    {
        capabilities.setVersion ( version );
    }
    capabilities.setCapability ( CapabilityType.PLATFORM, os );
    capabilities.setCapability ( CapabilityType.SUPPORTS_FINDING_BY_CSS, true );
    capabilities.setCapability ( "name", "Eclipse Package Drone Main Test" );

    if ( System.getenv ( "TRAVIS_JOB_NUMBER" ) != null )
    {
        capabilities.setCapability ( "tunnel-identifier", System.getenv ( "TRAVIS_JOB_NUMBER" ) );
        capabilities.setCapability ( "build", System.getenv ( "TRAVIS_BUILD_NUMBER" ) );
        capabilities.setCapability ( "tags", new String[] { "CI" } );
    }

    final RemoteWebDriver driver = new RemoteWebDriver ( new URL ( String.format ( "http://%s:%[email protected]%s/wd/hub", SAUCE_USER_NAME, SAUCE_ACCESS_KEY, SAUCE_URL ) ), capabilities );

    driver.setFileDetector ( new LocalFileDetector () );

    return driver;
}
 
Example 2
Source Project: flow   File: AbstractTestBenchTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets browser capabilities for the provided <code>browsers</code>.
 *
 * @param browsers
 *            a browsers list
 * @return the capabilities for the given <code>browsers</code>
 */
protected List<DesiredCapabilities> getBrowserCapabilities(
        Browser... browsers) {
    List<DesiredCapabilities> capabilities = new ArrayList<>();
    for (Browser browser : browsers) {
        DesiredCapabilities caps = browser.getDesiredCapabilities();

        if (USE_BROWSERSTACK) {
            if (browser.equals(Browser.IE11)) {
                caps.setVersion("11");
            }
            caps.setCapability("os", "Windows");
            caps.setCapability("os_version", "7");
            caps.setPlatform(Platform.WINDOWS);

            if (!BROWSERSTACK_IDENTIFIER.isEmpty()) {
                caps.setCapability("browserstack.localIdentifier",
                        BROWSERSTACK_IDENTIFIER);
            }
            caps.setCapability("build", "BrowserStack Tests"
                    + (BROWSERSTACK_IDENTIFIER.isEmpty() ? ""
                            : " [" + BROWSERSTACK_IDENTIFIER + "]"));

            caps.setCapability("acceptSslCerts", "true");
            caps.setCapability("resolution", "1680x1050");
        }

        caps.setCapability("project", "Flow");
        capabilities.add(caps);
    }
    return capabilities;
}
 
Example 3
Source Project: akita   File: CustomDriverProvider.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Задает options для запуска Firefox драйвера
 * options можно передавать, как системную переменную, например -Doptions=--load-extension=my-custom-extension
 *
 * @return FirefoxOptions
 */
private FirefoxOptions getFirefoxDriverOptions(DesiredCapabilities capabilities) {
    log.info("---------------Firefox Driver---------------------");
    FirefoxOptions firefoxOptions = !options[0].equals("") ? new FirefoxOptions().addArguments(options) : new FirefoxOptions();
    capabilities.setVersion(loadSystemPropertyOrDefault(CapabilityType.BROWSER_VERSION, VERSION_LATEST));
    firefoxOptions.setHeadless(getHeadless());
    firefoxOptions.merge(capabilities);
    return firefoxOptions;
}
 
Example 4
Source Project: glowroot   File: SauceLabs.java    License: Apache License 2.0 5 votes vote down vote up
public static WebDriver getWebDriver(String testName) throws MalformedURLException {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName(browserName);
    if (!Strings.isNullOrEmpty(browserVersion)) {
        capabilities.setVersion(browserVersion);
    }
    if (Strings.isNullOrEmpty(deviceName)) {
        // webdriver capabilities
        capabilities.setCapability("platform", platform);
        // currently tests fail with default nativeEvents=true
        // (can't select radio buttons on capture point page)
        capabilities.setCapability("nativeEvents", false);
    } else {
        // appium capabilities
        int index = platform.indexOf(' ');
        String platformName = platform.substring(0, index);
        String platformVersion = platform.substring(index + 1);
        capabilities.setCapability("platformName", platformName);
        capabilities.setCapability("platformVersion", platformVersion);
        capabilities.setCapability("deviceName", deviceName);
    }
    // pass credentials using environment variables
    String sauceUsername = System.getenv("SAUCE_USERNAME");
    String sauceAccessKey = System.getenv("SAUCE_ACCESS_KEY");
    capabilities.setCapability("tunnel-identifier", tunnelIdentifier);
    capabilities.setCapability("name", testName);
    capabilities.setCapability("extendedDebugging", true);
    return new RemoteWebDriver(new URL(
            "http://" + sauceUsername + ":" + sauceAccessKey + "@localhost:4445/wd/hub"),
            capabilities);
}
 
Example 5
private void instantiateWebDriver(DriverType driverType) throws MalformedURLException {
    System.out.println(" ");
    System.out.println("Local Operating System: " + operatingSystem);
    System.out.println("Local Architecture: " + systemArchitecture);
    System.out.println("Selected Browser: " + selectedDriverType);
    System.out.println("Connecting to Selenium Grid: " + useRemoteWebDriver);
    System.out.println(" ");

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (useRemoteWebDriver) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }

        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }

        desiredCapabilities.setBrowserName(selectedDriverType.toString());
        webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webDriver = driverType.getWebDriverObject(desiredCapabilities);
    }
}
 
Example 6
private void instantiateWebDriver(DriverType driverType) throws MalformedURLException {
    System.out.println(" ");
    System.out.println("Local Operating System: " + operatingSystem);
    System.out.println("Local Architecture: " + systemArchitecture);
    System.out.println("Selected Browser: " + selectedDriverType);
    System.out.println("Connecting to Selenium Grid: " + useRemoteWebDriver);
    System.out.println(" ");

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (useRemoteWebDriver) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }

        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }

        desiredCapabilities.setBrowserName(selectedDriverType.toString());
        webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webDriver = driverType.getWebDriverObject(desiredCapabilities);
    }
}
 
Example 7
private void instantiateWebDriver(DriverType driverType) throws MalformedURLException {
    System.out.println(" ");
    System.out.println("Local Operating System: " + operatingSystem);
    System.out.println("Local Architecture: " + systemArchitecture);
    System.out.println("Selected Browser: " + selectedDriverType);
    System.out.println("Connecting to Selenium Grid: " + useRemoteWebDriver);
    System.out.println(" ");

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (useRemoteWebDriver) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }

        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }

        desiredCapabilities.setBrowserName(selectedDriverType.toString());
        webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webDriver = driverType.getWebDriverObject(desiredCapabilities);
    }
}
 
Example 8
private void instantiateWebDriver(DriverType driverType) throws MalformedURLException {
    System.out.println(" ");
    System.out.println("Local Operating System: " + operatingSystem);
    System.out.println("Local Architecture: " + systemArchitecture);
    System.out.println("Selected Browser: " + selectedDriverType);
    System.out.println("Connecting to Selenium Grid: " + useRemoteWebDriver);
    System.out.println(" ");

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (useRemoteWebDriver) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }

        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }

        desiredCapabilities.setBrowserName(selectedDriverType.toString());
        webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webDriver = driverType.getWebDriverObject(desiredCapabilities);
    }
}
 
Example 9
private void instantiateWebDriver(DriverType driverType) throws MalformedURLException {
    System.out.println(" ");
    System.out.println("Local Operating System: " + operatingSystem);
    System.out.println("Local Architecture: " + systemArchitecture);
    System.out.println("Selected Browser: " + selectedDriverType);
    System.out.println("Connecting to Selenium Grid: " + useRemoteWebDriver);
    System.out.println(" ");

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (proxyEnabled) {
        Proxy proxy = new Proxy();
        proxy.setProxyType(MANUAL);
        proxy.setHttpProxy(proxyDetails);
        proxy.setSslProxy(proxyDetails);
        desiredCapabilities.setCapability(PROXY, proxy);
    }

    if (useRemoteWebDriver) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }

        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }

        desiredCapabilities.setBrowserName(selectedDriverType.toString());
        webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webDriver = driverType.getWebDriverObject(desiredCapabilities);
    }
}
 
Example 10
public LogSearchUIStories() {
  String dockerHost = System.getProperty("docker.host") != null ? System.getProperty("docker.host") : "localhost";
  System.setProperty("REMOTE_WEBDRIVER_URL", String.format("http://%s:4444/wd/hub", dockerHost));
  DesiredCapabilities capability = DesiredCapabilities.firefox();
  capability.setPlatform(Platform.LINUX);
  capability.setVersion("45.8.0");
  driverProvider = new RemoteWebDriverProvider(capability);
  StoryDataRegistry.INSTANCE.setWebDriverProvider(driverProvider);
  context = new SeleniumContext();
  configuredEmbedder().useExecutorService(new SameThreadExecutors().create(configuredEmbedder().embedderControls()));
}
 
Example 11
private void instantiateWebDriver(DriverType driverType) throws MalformedURLException {
    System.out.println(" ");
    System.out.println("Local Operating System: " + operatingSystem);
    System.out.println("Local Architecture: " + systemArchitecture);
    System.out.println("Selected Browser: " + selectedDriverType);
    System.out.println("Connecting to Selenium Grid: " + useRemoteWebDriver);
    System.out.println(" ");

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (useRemoteWebDriver) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }

        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }

        desiredCapabilities.setBrowserName(selectedDriverType.toString());
        webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webDriver = driverType.getWebDriverObject(desiredCapabilities);
    }
}
 
Example 12
private void instantiateWebDriver(DriverType driverType) throws MalformedURLException {
    System.out.println(" ");
    System.out.println("Local Operating System: " + operatingSystem);
    System.out.println("Local Architecture: " + systemArchitecture);
    System.out.println("Selected Browser: " + selectedDriverType);
    System.out.println("Connecting to Selenium Grid: " + useRemoteWebDriver);
    System.out.println(" ");

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (useRemoteWebDriver) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }

        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }

        desiredCapabilities.setBrowserName(selectedDriverType.toString());
        webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webDriver = driverType.getWebDriverObject(desiredCapabilities);
    }
}
 
Example 13
private void instantiateWebDriver(DriverType driverType) throws MalformedURLException {
    System.out.println(" ");
    System.out.println("Local Operating System: " + operatingSystem);
    System.out.println("Local Architecture: " + systemArchitecture);
    System.out.println("Selected Browser: " + selectedDriverType);
    System.out.println("Connecting to Selenium Grid: " + useRemoteWebDriver);
    System.out.println(" ");

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (useRemoteWebDriver) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }

        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }

        desiredCapabilities.setBrowserName(selectedDriverType.toString());
        webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webDriver = driverType.getWebDriverObject(desiredCapabilities);
    }
}
 
Example 14
private static WebDriver create(RunContext context, ProjectSettings settings, Boolean isGrid, String remoteUrl) {
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setPlatform(context.Platform);
    if (!context.BrowserVersion.equalsIgnoreCase("default")) {
        caps.setVersion(context.BrowserVersion);
    }
    caps.merge(getCapability(context.BrowserName, settings));
    return create(context.BrowserName, caps, settings, isGrid, remoteUrl);
}
 
Example 15
Source Project: carina   File: AbstractCapabilities.java    License: Apache License 2.0 5 votes vote down vote up
protected DesiredCapabilities initBaseCapabilities(DesiredCapabilities capabilities, String browser, String testName) {

        // TODO: should use provide capabilities as an argument for getPlatform call below?
        String platform = Configuration.getPlatform();
        if (!platform.equals("*")) {
            capabilities.setPlatform(Platform.extractFromSysProperty(platform));
        }

        capabilities.setBrowserName(browser);

        // Selenium 3.4 doesn't support '*'. Only explicit or empty browser version should be provided
        String browserVersion = Configuration.get(Parameter.BROWSER_VERSION);
        if ("*".equalsIgnoreCase(browserVersion)) {
            browserVersion = "";
        }
        capabilities.setVersion(browserVersion);
        capabilities.setCapability("name", testName);

        Proxy proxy = setupProxy();
        if (proxy != null) {
            capabilities.setCapability(CapabilityType.PROXY, proxy);
        }

        // add capabilities based on dynamic _config.properties variables
        capabilities = initCapabilities(capabilities);
        
        return capabilities;
    }
 
Example 16
private void instantiateWebDriver(DriverType driverType) throws MalformedURLException {
    System.out.println(" ");
    System.out.println("Local Operating System: " + operatingSystem);
    System.out.println("Local Architecture: " + systemArchitecture);
    System.out.println("Selected Browser: " + selectedDriverType);
    System.out.println("Connecting to Selenium Grid: " + useRemoteWebDriver);
    System.out.println(" ");

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (useRemoteWebDriver) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }

        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }

        desiredCapabilities.setBrowserName(selectedDriverType.toString());
        webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webDriver = driverType.getWebDriverObject(desiredCapabilities);
    }
}
 
Example 17
private void instantiateWebDriver(DriverType driverType) throws MalformedURLException {
    System.out.println(" ");
    System.out.println("Local Operating System: " + operatingSystem);
    System.out.println("Local Architecture: " + systemArchitecture);
    System.out.println("Selected Browser: " + selectedDriverType);
    System.out.println("Connecting to Selenium Grid: " + useRemoteWebDriver);
    System.out.println(" ");

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (useRemoteWebDriver) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }

        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }

        desiredCapabilities.setBrowserName(selectedDriverType.toString());
        webDriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webDriver = driverType.getWebDriverObject(desiredCapabilities);
    }
}
 
Example 18
Source Project: selenium   File: DriverFactoryTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testShouldReturnDriverWhereTheMostCapabilitiesMatch_lotsOfRegisteredDrivers() {
  DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
  desiredCapabilities.setBrowserName(FIREFOX);
  desiredCapabilities.setVersion("");
  desiredCapabilities.setJavascriptEnabled(true);
  desiredCapabilities.setPlatform(Platform.ANY);

  assertEquals(FIREFOX, factory.getProviderMatching(desiredCapabilities)
      .getProvidedCapabilities().getBrowserName());
}
 
Example 19
public void createSessionWithDefaultCapabilities() {
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setVersion("");
    driver = new JavaDriver(desiredCapabilities, desiredCapabilities);
}
 
Example 20
public DesiredCapabilities createCapabilities(final DriverConfig cfg) {

        // Set IEDriver for Local Mode
        if (cfg.getMode() == DriverMode.LOCAL) {
            if (cfg.getIeDriverPath() != null) {
                System.setProperty("webdriver.ie.driver", cfg.getIeDriverPath());
            } else {
                if (System.getenv("webdriver.ie.driver") != null) {
                    System.out.println("Get IE Driver from property:" + System.getenv("webdriver.ie.driver"));
                    System.setProperty("webdriver.ie.driver", System.getenv("webdriver.ie.driver"));
                } else {
                    try {
                        handleExtractResources();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }

        }

        DesiredCapabilities capability = DesiredCapabilities.internetExplorer();

        capability.setBrowserName(DesiredCapabilities.internetExplorer().getBrowserName());

        if (cfg.isEnableJavascript()) {
            capability.setJavascriptEnabled(true);
        } else {
            capability.setJavascriptEnabled(false);
        }

        capability.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capability.setCapability("ignoreZoomSetting", true);

        if (cfg.getBrowserVersion() != null) {
            capability.setVersion(cfg.getBrowserVersion());
        }

        if (cfg.getWebPlatform() != null) {
            capability.setPlatform(cfg.getWebPlatform());
        }

        if (cfg.getProxyHost() != null) {
            Proxy proxy = cfg.getProxy();
            capability.setCapability(CapabilityType.PROXY, proxy);
        }

        capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        return capability;
    }