コード例 #1
0
 public DesiredCapabilities getDesiredCapabilities() {
   DesiredCapabilities dc = new DesiredCapabilities();
   if (isFrameworkProperties) {
     dc.merge(getDCFrameworkProp());
   }
   dc.merge(getDCClient());
   dc.merge(getDCJvm());
   return dc;
 }
コード例 #2
0
 public DesiredCapabilities(Capabilities... others) {
   for (Capabilities caps : others) {
     if (caps != null) {
       merge(caps);
     }
   }
 }
コード例 #3
0
  @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);
    }
  }
コード例 #4
0
 @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;
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 public DesiredCapabilities(Capabilities other) {
   if (other != null) {
     merge(other);
   }
 }