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

The following examples show how to use org.openqa.selenium.remote.DesiredCapabilities#merge() . 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: vividus   File: VividusWebDriverFactory.java    License: Apache License 2.0 6 votes vote down vote up
private void setBaseDesiredCapabilities(VividusWebDriver vividusWebDriver, RunningStory runningStory)
{
    DesiredCapabilities desiredCapabilities = vividusWebDriver.getDesiredCapabilities();
    desiredCapabilities.merge(webDriverManagerContext.getParameter(
            WebDriverManagerParameter.DESIRED_CAPABILITIES));
    webDriverManagerContext.reset(WebDriverManagerParameter.DESIRED_CAPABILITIES);
    if (runningStory != null)
    {
        Scenario scenario = runningStory.getRunningScenario().getScenario();
        Meta mergedMeta = mergeMeta(runningStory.getStory(), scenario);
        MetaWrapper metaWrapper = new MetaWrapper(mergedMeta);
        ControllingMetaTag.setDesiredCapabilitiesFromMeta(desiredCapabilities, metaWrapper);
        if (remoteExecution)
        {
            desiredCapabilities.setCapability(SauceLabsCapabilityType.NAME, runningStory.getName());
        }
        else
        {
            if (scenario != null)
            {
                ControllingMetaTag.BROWSER_NAME.setCapability(desiredCapabilities, metaWrapper);
            }
        }
    }
}
 
Example 2
Source Project: teasy   File: AndroidChromeCaps.java    License: MIT License 5 votes vote down vote up
public DesiredCapabilities get() {
    DesiredCapabilities caps = getAndroidChromeCaps();
    if (!this.customCaps.asMap().isEmpty()) {
        caps.merge(this.customCaps);
    }
    return caps;
}
 
Example 3
Source Project: teasy   File: IosNativeAppCaps.java    License: MIT License 5 votes vote down vote up
public DesiredCapabilities get() {
    DesiredCapabilities caps = new DesiredCapabilities();
    if (!this.customCaps.asMap().isEmpty()) {
        caps.merge(this.customCaps);
    }
    if (this.customCaps.getBrowserName().equals(DriverFactory.NATIVE_APP)) {
        this.customCaps.setBrowserName(DriverFactory.EMPTY);
    }
    return caps;
}
 
Example 4
Source Project: teasy   File: SafariTechPreviewCaps.java    License: 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 5
Source Project: teasy   File: IosSafariCaps.java    License: MIT License 5 votes vote down vote up
public DesiredCapabilities get() {
    DesiredCapabilities caps = getIOSSafariCaps();
    if (!this.customCaps.asMap().isEmpty()) {
        caps.merge(this.customCaps);
    }
    return caps;
}
 
Example 6
Source Project: teasy   File: AndroidNativeAppCaps.java    License: MIT License 5 votes vote down vote up
public DesiredCapabilities get() {
    DesiredCapabilities caps = new DesiredCapabilities();
    if (!this.customCaps.asMap().isEmpty()) {
        caps.merge(this.customCaps);
    }
    if (this.customCaps.getBrowserName().equals(DriverFactory.NATIVE_APP)) {
        this.customCaps.setBrowserName(DriverFactory.EMPTY);
    }
    return caps;
}
 
Example 7
Source Project: teasy   File: TeasyDriver.java    License: MIT License 5 votes vote down vote up
public WebDriver init(DesiredCapabilities extraCaps) {
    DriverFactory driverFactory;
    URL gridUrl = getGridHubUrl();
    boolean isHeadless = Configuration.headless;
    if (Configuration.runWithGrid) {
        driverFactory = new RemoteDriverFactory(Configuration.browser, Configuration.platform, extraCaps.merge(Configuration.customCaps), isHeadless, gridUrl);
    } else {
        driverFactory = new StandaloneDriverFactory(Configuration.browser, Configuration.platform, extraCaps.merge(Configuration.customCaps), isHeadless, gridUrl);
    }

    return driverFactory.get();
}
 
Example 8
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 9
Source Project: agent   File: AndroidDevice.java    License: MIT License 4 votes vote down vote up
@Override
protected Capabilities newCaps(Capabilities capsToMerge) {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
    capabilities.setCapability(AndroidMobileCapabilityType.UNICODE_KEYBOARD, true);
    capabilities.setCapability(AndroidMobileCapabilityType.RESET_KEYBOARD, true);
    capabilities.setCapability("recreateChromeDriverSessions", true);

    // 加速初始化速度
    capabilities.setCapability("skipServerInstallation", true);
    capabilities.setCapability("skipDeviceInitialization", true);
    capabilities.setCapability("skipUnlock", true);
    // 这个暂时用不到 先skip提升性能
    capabilities.setCapability("skipLogcatCapture", true);

    if (!greaterOrEqualsToAndroid5()) { // 小于安卓5,必须指定app,否则会创建driver失败
        capabilities.setCapability("appPackage", "io.appium.android.apis");
        capabilities.setCapability("appActivity", "io.appium.android.apis.ApiDemos");
    }

    // **** 以上capabilities可被传入的caps覆盖 ****

    capabilities.merge(capsToMerge);

    // **** 以下capabilities具有更高优先级,将覆盖传入的caps ****

    if (greaterOrEqualsToAndroid5()) {
        capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2); // UIAutomation2 is only supported since Android 5.0 (Lollipop)
    } else {
        capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UIAutomator1");
    }
    capabilities.setCapability(AndroidMobileCapabilityType.SYSTEM_PORT, PortProvider.getUiautomator2ServerAvailablePort());

    capabilities.setCapability("chromedriverPort", PortProvider.getAndroidChromeDriverAvailablePort());
    String chromedriverFilePath = getChromedriverFilePath();
    if (StringUtils.isEmpty(chromedriverFilePath)) {
        capabilities.setCapability(AndroidMobileCapabilityType.CHROMEDRIVER_EXECUTABLE, chromedriverFilePath);
    }

    capabilities.setCapability(MobileCapabilityType.UDID, getId());
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, mobile.getName());
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, mobile.getSystemVersion());
    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, NEW_COMMAND_TIMEOUT);

    return capabilities;
}
 
Example 10
Source Project: agent   File: IosDevice.java    License: MIT License 4 votes vote down vote up
@Override
protected Capabilities newCaps(Capabilities capsToMerge) {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
    capabilities.setCapability("waitForQuiescence", false);
    capabilities.setCapability("skipLogCapture", true);
    capabilities.setCapability("useJSONSource", true); // Get JSON source from WDA and parse into XML on Appium server. This can be much faster, especially on large devices.

    // https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md
    String xcodeOrgId = App.getProperty("xcodeOrgId");
    if (!StringUtils.isEmpty(xcodeOrgId)) {
        capabilities.setCapability("xcodeOrgId", xcodeOrgId);
    }
    String xcodeSigningId = App.getProperty("xcodeSigningId");
    if (!StringUtils.isEmpty(xcodeSigningId)) {
        capabilities.setCapability("xcodeSigningId", xcodeSigningId);
    }
    String updatedWDABundleId = App.getProperty("updatedWDABundleId");
    if (!StringUtils.isEmpty(updatedWDABundleId)) {
        capabilities.setCapability("updatedWDABundleId", updatedWDABundleId);
    }

    // **** 以上capabilities可被传入的caps覆盖 ****

    capabilities.merge(capsToMerge);

    // **** 以下capabilities具有更高优先级,将覆盖传入的caps ****

    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST);
    capabilities.setCapability(IOSMobileCapabilityType.WDA_LOCAL_PORT, PortProvider.getWdaLocalAvailablePort());

    capabilities.setCapability("mjpegServerPort", PortProvider.getWdaMjpegServerAvailablePort());
    capabilities.setCapability("webkitDebugProxyPort", PortProvider.getWebkitDebugProxyAvalilablePort());

    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, mobile.getName());
    capabilities.setCapability(MobileCapabilityType.UDID, getId());
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, mobile.getSystemVersion());
    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, NEW_COMMAND_TIMEOUT);

    return capabilities;
}