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

The following examples show how to use org.openqa.selenium.remote.DesiredCapabilities#safari() . 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: SafariTechPreviewCaps.java    From teasy with MIT License 5 votes vote down vote up
public MutableCapabilities get() {
    DesiredCapabilities safariCaps = DesiredCapabilities.safari();
    SafariOptions options = new SafariOptions();
    options.setUseTechnologyPreview(true);
    safariCaps.setCapability(SafariOptions.CAPABILITY, options);
    setLoggingPrefs(safariCaps);
    if (!this.customCaps.asMap().isEmpty()) {
        safariCaps.merge(this.customCaps);
    }
    return safariCaps;
}
 
Example 2
Source File: BrowserDriver.java    From SWET with MIT License 5 votes vote down vote up
private static DesiredCapabilities capabilitiesSafari() {
	DesiredCapabilities capabilities = DesiredCapabilities.safari();
	SafariOptions options = new SafariOptions();
	// TODO: need to conditionally compile:
	// With Selenium 3.13.x
	// setUseCleanSession
	// no longer not exist in org.openqa.selenium.safari.SafariOptions
	// options.setUseCleanSession(true);
	capabilities.setCapability(SafariOptions.CAPABILITY, options);
	return capabilities;
}
 
Example 3
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 4
Source File: SauceLabsWebDriverHelper.java    From rice with Educational Community License v2.0 4 votes vote down vote up
/**
 * <p>
 * Saucelabs setUp.
 * </p><p>
 * Creates a {@link org.openqa.selenium.remote.RemoteWebDriver} instance with the DesiredCapabilities as configured
 * using the JVM arguments described as SAUCE_ Constants in this class.  After setUp the WebDriver can be accessed via
 * {@see #getDriver}.  You'll also need {@see #getSessionId} for when you call {@see #tearDown}
 * </p>
 *
 * @param className class name of the test being setup as a String
 * @param testName test name of the test being setup as a String
 * @throws Exception
 */
public void setUp(String className, String testName) throws Exception {
    if (System.getProperty(REMOTE_DRIVER_SAUCELABS_PROPERTY) == null) { // dup guard so WebDriverUtils doesn't have to be used.
        return;
    }

    if (System.getProperty(SAUCE_USER_PROPERTY) == null || System.getProperty(SAUCE_KEY_PROPERTY) == null) {
        Assert.fail("-D" + SAUCE_USER_PROPERTY + " and -D" + SAUCE_KEY_PROPERTY + " must be set to saucelabs user and access key.");
    }

    DesiredCapabilities capabilities = null;
    if ("ff".equalsIgnoreCase(System.getProperty(SAUCE_BROWSER_PROPERTY))) {
        capabilities = DesiredCapabilities.firefox();
    } else if ("ie".equalsIgnoreCase(System.getProperty(SAUCE_BROWSER_PROPERTY)))  {
        capabilities = DesiredCapabilities.internetExplorer();
        capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
            System.getProperty(SAUCE_IE_INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS_PROPERTY, "true"));
    } else if ("chrome".equalsIgnoreCase(System.getProperty(SAUCE_BROWSER_PROPERTY)))  {
        capabilities = DesiredCapabilities.chrome();
    } else if ("opera".equalsIgnoreCase(System.getProperty(SAUCE_BROWSER_PROPERTY)))  {
        capabilities = DesiredCapabilities.opera();
    } else if ("android".equalsIgnoreCase(System.getProperty(SAUCE_BROWSER_PROPERTY)))  {
        capabilities = DesiredCapabilities.android();
    } else if ("safari".equalsIgnoreCase(System.getProperty(SAUCE_BROWSER_PROPERTY)))  {
        capabilities = DesiredCapabilities.safari();
    } else if ("ipad".equalsIgnoreCase(System.getProperty(SAUCE_BROWSER_PROPERTY)))  {
        capabilities = DesiredCapabilities.ipad();
    } else if ("iphone".equalsIgnoreCase(System.getProperty(SAUCE_BROWSER_PROPERTY)))  {
        capabilities = DesiredCapabilities.iphone();
    } else {
        capabilities = DesiredCapabilities.firefox();
    }

    String version = System.getProperty(SAUCE_VERSION_PROPERTY);
    if (version == null || "0".equals(version)) { // Blank or 0 leaves version blank for use with chrome

        if (!"chrome".equalsIgnoreCase(System.getProperty(SAUCE_BROWSER_PROPERTY))) {
            throw new RuntimeException("Blank or 0 version for a browser not chrome " + System.getProperty(SAUCE_BROWSER_PROPERTY));
        }

        capabilities.setCapability("version", ""); // saucelabs requires blank for chrome (latest version)
    } else {
        capabilities.setCapability("version", version); // saucelabs requires blank for chrome (latest version)
    }

    capabilities.setCapability("platform", System.getProperty(SAUCE_PLATFORM_PROPERTY, Platform.UNIX.toString()).replaceAll("_", " "));
    capabilities.setCapability("idle-timeout", Integer.parseInt(System.getProperty(SAUCE_IDLE_TIMEOUT_SECONDS_PROPERTY, "180")));
    capabilities.setCapability("max-duration", Integer.parseInt(System.getProperty(SAUCE_MAX_DURATION_SECONDS_PROPERTY, "600")));
    capabilities.setCapability("name",  className + "." + testName + "-" + AutomatedFunctionalTestUtils.DTS);
    capabilities.setCapability("disable-popup-handler", System.getProperty(SAUCE_POPUP_PROPERTY, "false"));
    capabilities.setCapability("public", System.getProperty(SAUCE_SHARE_PROPERTY, "public restricted"));

    System.out.println("Requesting Saucelabs RemoteWebDriver with DesiredCapabilities of " + capabilities.toString());

    this.driver = new RemoteWebDriver(
            new URL("http://" + authentication.getUsername() + ":" + authentication.getAccessKey() + "@ondemand.saucelabs.com:80/wd/hub"),
            capabilities);
    this.sessionId = ((RemoteWebDriver)driver).getSessionId().toString();

    System.out.println("SauceLabs job can be viewed at https://saucelabs.com/jobs/" + this.sessionId);
}
 
Example 5
Source File: SafariCapabilities.java    From carina with Apache License 2.0 4 votes vote down vote up
public DesiredCapabilities getCapability(String testName) {
    DesiredCapabilities capabilities = DesiredCapabilities.safari();
    capabilities = initBaseCapabilities(capabilities, BrowserType.SAFARI, testName);
    return capabilities;
}