@Test
  public void whenGetCapabilitiesFromRunningSessionThenItShouldBeSerializable() {
    RemoteWebDriver driver = new RemoteWebDriver(HUB_URL, DesiredCapabilities.firefox());

    Capabilities initializedCapabilities = driver.getCapabilities();

    assertTrue(
        "Capabilities obtained from running session should be serializable",
        initializedCapabilities instanceof Serializable);

    driver.quit();
  }
예제 #2
0
  private CompoundHandler determineAugmentation(
      RemoteWebDriver driver, Map<String, AugmenterProvider> augmentors, Object objectToAugment) {
    Map<String, ?> capabilities = driver.getCapabilities().asMap();

    CompoundHandler handler = new CompoundHandler(driver, objectToAugment);

    for (Map.Entry<String, ?> capabilityName : capabilities.entrySet()) {
      AugmenterProvider augmenter = augmentors.get(capabilityName.getKey());
      if (augmenter == null) {
        continue;
      }

      Object value = capabilityName.getValue();
      if (value instanceof Boolean && !((Boolean) value)) {
        continue;
      }

      handler.addCapabilityHander(
          augmenter.getDescribedInterface(), augmenter.getImplementation(value));
    }
    return handler;
  }