public DesiredCapabilities getDesiredCapabilities() { DesiredCapabilities dc = new DesiredCapabilities(); if (isFrameworkProperties) { dc.merge(getDCFrameworkProp()); } dc.merge(getDCClient()); dc.merge(getDCJvm()); return dc; }
public DesiredCapabilities(Capabilities... others) { for (Capabilities caps : others) { if (caps != null) { merge(caps); } } }
@Override public WebDriver newWebDriver(Capabilities capabilities, ConfigurationProperties configuration) { if (!available) { throw new ConfigurationException("WebDriver " + webDriverClassName + " is not available."); } try { DesiredCapabilities defaultCapabilities = newDefaultCapabilities(); if (defaultCapabilities != null) { defaultCapabilities.merge(capabilities); capabilities = defaultCapabilities; } if (capabilities != null && !capabilities.asMap().isEmpty()) { ArrayList<Object> argsList = new ArrayList<>(Arrays.asList(args)); argsList.add(0, capabilities); try { return newInstance(webDriverClass, configuration, argsList.toArray()); } catch (NoSuchMethodException e) { // NOPMD EmptyCatchBlock // Ignore capabilities. } } return newInstance(webDriverClass, configuration, args); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new ConfigurationException("Can't create new WebDriver instance", e); } }
@Override public WebDriver newInstance(DriverOptions driverOptions) { DesiredCapabilities caps = setupProxy(DesiredCapabilities.safari(), driverOptions); caps.merge(driverOptions.getCapabilities()); SafariDriver driver = new SafariDriver(caps); setInitialWindowSize(driver, driverOptions); return driver; }
private static DesiredCapabilities getAndroidCapabilities(DesiredCapabilities userPrefs) { DesiredCapabilities caps = DesiredCapabilities.android(); caps.setCapability(CapabilityType.TAKES_SCREENSHOT, true); caps.setCapability(CapabilityType.ROTATABLE, true); caps.setCapability(CapabilityType.SUPPORTS_BROWSER_CONNECTION, true); if (userPrefs != null) { caps.merge(userPrefs); } return caps; }
protected WebDriver createHtmlUnitDriver() { DesiredCapabilities capabilities = DesiredCapabilities.htmlUnitWithJs(); capabilities.merge(createCommonCapabilities()); capabilities.setCapability(HtmlUnitDriver.INVALIDSELECTIONERROR, true); capabilities.setCapability(HtmlUnitDriver.INVALIDXPATHERROR, false); if (browser.indexOf(':') > -1) { // Use constants BrowserType.IE, BrowserType.FIREFOX, BrowserType.CHROME etc. String emulatedBrowser = browser.replaceFirst("htmlunit:(.*)", "$1"); capabilities.setVersion(emulatedBrowser); } return new HtmlUnitDriver(capabilities); }
public DesiredCapabilities(Capabilities other) { if (other != null) { merge(other); } }