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

The following examples show how to use org.openqa.selenium.remote.DesiredCapabilities#setPlatform() . 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: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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 2
Source File: AbstractTest.java    From selenium-grid-extensions with Apache License 2.0 5 votes vote down vote up
private DesiredCapabilities firefoxWithSikuli() {
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setBrowserName("firefox");
    desiredCapabilities.setPlatform(Platform.ANY);
    desiredCapabilities.setCapability("sikuliExtension", true);
    return desiredCapabilities;
}
 
Example 3
Source File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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 4
Source File: SafariCapabilitiesFactory.java    From seleniumtestsframework with Apache License 2.0 5 votes vote down vote up
public DesiredCapabilities createCapabilities(final DriverConfig cfg) {
    DesiredCapabilities capability = null;
    capability = DesiredCapabilities.safari();

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

    capability.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
    capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, 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);
    }

    return capability;
}
 
Example 5
Source File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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
Source File: InternetExplorerOptionsTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSetIeOptionsCapabilityWhenConstructedFromExistingCapabilities() {
  InternetExplorerOptions expected = new InternetExplorerOptions();
  expected.setCapability("requireWindowFocus", true);

  DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
  desiredCapabilities.setPlatform(Platform.WINDOWS);
  InternetExplorerOptions seen = new InternetExplorerOptions(desiredCapabilities);
  seen.setCapability("requireWindowFocus", true);

  assertThat(seen.getCapability(IE_OPTIONS)).isEqualTo(expected.getCapability(IE_OPTIONS));
}
 
Example 7
Source File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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
Source File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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
Source File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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 10
Source File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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 11
Source File: WebDriverFactory.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
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 12
Source File: LogSearchUIStories.java    From ambari-logsearch with Apache License 2.0 5 votes vote down vote up
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 13
Source File: AbstractTestBenchTest.java    From flow with 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 14
Source File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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 15
Source File: AppiumFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
private void instantiateWebDriver(AppiumDriverType appiumDriverType) throws MalformedURLException {
    System.out.println("Current Appium Config Selection: " + selectedDriverConfiguration);
    System.out.println("Current Appium Server Location: " + APPIUM_SERVER_LOCATION);
    System.out.println("Connecting to Selenium Grid: " + USE_SELENIUM_GRID);

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    if (Boolean.getBoolean("enableDebugMode")) {
        desiredCapabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "3600");
    }
    Optional.ofNullable(System.getProperty("device_id", null))
            .ifPresent(deviceID -> desiredCapabilities.setCapability(MobileCapabilityType.UDID, deviceID));
    if (USE_SELENIUM_GRID) {
        URL seleniumGridURL = new URL(System.getProperty("gridURL"));
        String desiredVersion = System.getProperty("desiredVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");

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

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

        desiredCapabilities.setBrowserName(selectedDriverConfiguration.toString());
        driver = new AppiumDriver(seleniumGridURL, desiredCapabilities);
    } else {
        driver = appiumDriverType.createAppiumObject(new URL(APPIUM_SERVER_LOCATION), desiredCapabilities)
                .setActivity(currentActivity)
                .getAppiumDriver();
    }
}
 
Example 16
Source File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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
Source File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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 File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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 19
Source File: DriverFactory.java    From Mastering-Selenium-WebDriver-3.0-Second-Edition with MIT License 5 votes vote down vote up
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 20
Source File: IECapabilitiesFactory.java    From seleniumtestsframework with Apache License 2.0 4 votes vote down vote up
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;
    }