Package org.openqa.selenium.remote

Examples of org.openqa.selenium.remote.DesiredCapabilities


        assertNull(browser);
    }

    @Test
    public void shouldHaveProxyInCapability() {
        final DesiredCapabilities capabilities = config.createCapabilities();
        assertThat(capabilities.getCapability(CapabilityType.PROXY), is(notNullValue()));
    }
View Full Code Here


  }
 
  @Override
  public WebDriver createDriver(File browserPath, Map<String, String> driverOptions)
  {
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability("chrome.binary", browserPath.getPath());
   
    for(String optionKey : driverOptions.keySet())
    {
      String optionValue = driverOptions.get(optionKey);
      capabilities.setCapability(optionKey, optionValue);
    }
   
    // TODO: we should switch over to using chrome options instead
    return new ChromeDriver(capabilities);
  }
View Full Code Here

  }

  @Test
  @Ignore(products = CORE, value = "core does not reset port number if -debugproxy is omitted")
  public void testDefaultPort() {
    DesiredCapabilities c = new DesiredCapabilities();
    c.setCapability(OperaSettings.Capability.PORT.getCapability(), -1);

    TestDriver a = new TestDriverBuilder().using(c).get();
    assertEquals(7001, a.preferences().get("Developer Tools", "Proxy Port").getValue());
    a.quit();
  }
View Full Code Here

    a.quit();
  }

  @Test
  public void testRandomPort() {
    DesiredCapabilities c = new DesiredCapabilities();
    c.setCapability(OperaSettings.Capability.PORT.getCapability(), 0);

    TestDriver a;
    try {
      a = new TestDriverBuilder().using(c).get();
    } catch (Exception e) {
View Full Code Here

    assertThat(profile, matchesProfile(data));
  }

  @Test
  public void fromCapabilitiesWithProfile() throws Throwable {
    DesiredCapabilities caps = DesiredCapabilities.opera();
    Map<String, String> profileMap = ImmutableMap.of(OperaProfile.BASE64_JSON_KEY, VALID_BASE64_ENCODED_PROFILE);
    caps.setCapability("opera.profile", profileMap);

    // Shouldn't throw
    new OperaSettings().merge(caps);
  }
View Full Code Here

    assertEquals(true, capabilities.getCapability(AUTOSTART.getCapability()));
  }

  @Test
  public void surplusCapabilitiesAreIncludedWhenConvertedToCapabilities() {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("foo", "bar");

    settings.merge(capabilities);

    for (Map.Entry<String, ?> capability : settings.toCapabilities().asMap().entrySet()) {
      if (capability.getKey().equals("foo") && capability.getValue().equals("bar")) {
View Full Code Here

        FirefoxProfile profile = new FirefoxProfile();
        // This flag avoids granting the access to the camera
        profile.setPreference("media.navigator.permission.disabled",
            true);
        if (remoteNode != null) {
          DesiredCapabilities capabilities = new DesiredCapabilities();
          capabilities.setCapability(FirefoxDriver.PROFILE, profile);
          capabilities.setBrowserName(DesiredCapabilities.firefox()
              .getBrowserName());

          driver = new RemoteWebDriver(new URL("http://"
              + hostAddress + ":" + hubPort + "/wd/hub"),
              capabilities);
        } else {
          driver = new FirefoxDriver(profile);
        }

        if (!usePhysicalCam && video != null) {
          launchFakeCam();
        }

      } else if (driverClass.equals(ChromeDriver.class)) {
        String chromedriver = null;
        if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_LINUX) {
          chromedriver = "chromedriver";
        } else if (SystemUtils.IS_OS_WINDOWS) {
          chromedriver = "chromedriver.exe";
        }
        System.setProperty("webdriver.chrome.driver", new File(
            "target/webdriver/" + chromedriver).getAbsolutePath());
        ChromeOptions options = new ChromeOptions();

        // This flag avoids grant the camera
        options.addArguments("--use-fake-ui-for-media-stream");

        // This flag avoids warning in chrome. See:
        // https://code.google.com/p/chromedriver/issues/detail?id=799
        options.addArguments("--test-type");

        if (!usePhysicalCam) {
          // This flag makes using a synthetic video (green with
          // spinner) in webrtc. Or it is needed to combine with
          // use-file-for-fake-video-capture to use a file faking the
          // cam
          options.addArguments("--use-fake-device-for-media-stream");

          if (video != null) {
            options.addArguments("--use-file-for-fake-video-capture="
                + video);

            // Alternative: lauch fake cam also in Chrome
            // launchFakeCam();
          }
        }

        if (remoteNode != null) {
          DesiredCapabilities capabilities = new DesiredCapabilities();
          capabilities.setCapability(ChromeOptions.CAPABILITY,
              options);
          capabilities.setBrowserName(DesiredCapabilities.chrome()
              .getBrowserName());
          driver = new RemoteWebDriver(new URL("http://"
              + hostAddress + ":" + hubPort + "/wd/hub"),
              capabilities);
View Full Code Here

   * reflected in the capabilities.
   *
   * @return Capabilities for Opera with these settings
   */
  public Capabilities toCapabilities() {
    DesiredCapabilities capabilities = DesiredCapabilities.opera();

    for (CapabilityInstance option : options.values()) {
      if (option.getValue() == null) {
        continue;
      }

      capabilities.setCapability(option.getCapability(), option.getValue());
    }

    return capabilities.merge(surplusCapabilities);
  }
View Full Code Here

    }
    return new Object[] {getCapabilities()};
  }

  private DesiredCapabilities getCapabilities() {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setJavascriptEnabled(true);

    for (Capability capability : webDriverCapabilities) {
      Object value = capability.getValue();
      if (value != null && (!String.class.isInstance(value) || StringUtils.isNotBlank((String)value))) {
        capabilities.setCapability(capability.getName(),capability.getValue());
      } else if (capability.getList() != null && !capability.getList().isEmpty()) {
        capabilities.setCapability(capability.getName(),capability.getList());
      } else if (capability.getMap() != null && !capability.getMap().isEmpty()) {
        capabilities.setCapability(capability.getName(),capability.getMap());
      }
    }

    return capabilities;
  }
View Full Code Here

    return capabilities;
  }

  private WebDriver createDefaultWebDriver() throws Exception {
    DesiredCapabilities capabilities = getCapabilities();
    if (StringUtils.isBlank(capabilities.getBrowserName())) {
      capabilities.setBrowserName(BrowserType.HTMLUNIT);
    }
    if (StringUtils.isBlank(capabilities.getVersion())) {
      capabilities.setVersion(browserVersion.replaceAll("(\\D+)_(\\d.*)?", "$1-$2").replaceAll("_", " ").toLowerCase());
    }
    return new QuietHtmlUnitDriver(getCapabilities(), debug);
  }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.remote.DesiredCapabilities

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.