Java Code Examples for org.openqa.selenium.ImmutableCapabilities#copyOf()

The following examples show how to use org.openqa.selenium.ImmutableCapabilities#copyOf() . 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 File: LocalNode.java    From selenium with Apache License 2.0 6 votes vote down vote up
private Session createExternalSession(ActiveSession other, URI externalUri) {
  Capabilities toUse = ImmutableCapabilities.copyOf(other.getCapabilities());

  // Rewrite the se:options if necessary
  Object rawSeleniumOptions = other.getCapabilities().getCapability("se:options");
  if (rawSeleniumOptions instanceof Map) {
    @SuppressWarnings("unchecked") Map<String, Object> original = (Map<String, Object>) rawSeleniumOptions;
    Map<String, Object> updated = new TreeMap<>(original);

    Object cdp = original.get("cdp");
    String cdpPath = String.format("/session/%s/se/cdp", other.getId());
    updated.put("cdp", rewrite(cdpPath));

    toUse = new PersistentCapabilities(toUse).setCapability("se:options", updated);
  }

  return new Session(other.getId(), externalUri, toUse);
}
 
Example 2
Source File: OneShotNode.java    From selenium with Apache License 2.0 6 votes vote down vote up
private OneShotNode(
  Tracer tracer,
  EventBus events,
  String registrationSecret,
  UUID id,
  URI uri,
  URI gridUri,
  Capabilities stereotype,
  WebDriverInfo driverInfo) {
  super(tracer, id, uri);

  this.registrationSecret = registrationSecret;
  this.events = Require.nonNull("Event bus", events);
  this.gridUri = Require.nonNull("Public Grid URI", gridUri);
  this.stereotype = ImmutableCapabilities.copyOf(Require.nonNull("Stereotype", stereotype));
  this.driverInfo = Require.nonNull("Driver info", driverInfo);
}
 
Example 3
Source File: BaseActiveSession.java    From selenium with Apache License 2.0 6 votes vote down vote up
protected BaseActiveSession(
    SessionId id,
    URL url,
    Dialect downstream,
    Dialect upstream,
    Capabilities capabilities) {
  URI uri = null;
  try {
    uri = Require.nonNull("URL", url).toURI();
  } catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
  }

  this.session = new Session(
      Require.nonNull("Session id", id),
      uri,
      ImmutableCapabilities.copyOf(Require.nonNull("Capabilities", capabilities)));

  this.downstream = Require.nonNull("Downstream dialect", downstream);
  this.upstream = Require.nonNull("Upstream dialect", upstream);
}
 
Example 4
Source File: DockerSessionFactory.java    From selenium with Apache License 2.0 5 votes vote down vote up
public DockerSessionFactory(
    Tracer tracer,
    HttpClient.Factory clientFactory,
    Docker docker,
    Image image,
    Capabilities stereotype) {
  this.tracer = Require.nonNull("Tracer", tracer);
  this.clientFactory = Require.nonNull("HTTP client", clientFactory);
  this.docker = Require.nonNull("Docker command", docker);
  this.image = Require.nonNull("Docker image", image);
  this.stereotype = ImmutableCapabilities.copyOf(
      Require.nonNull("Stereotype", stereotype));
}
 
Example 5
Source File: CreateSessionRequest.java    From selenium with Apache License 2.0 5 votes vote down vote up
public CreateSessionRequest(
    Set<Dialect> downstreamDialects,
    Capabilities capabilities,
    Map<String, Object> metadata) {
  this.downstreamDialects = ImmutableSet.copyOf(
      Require.nonNull("Downstream dialects", downstreamDialects));
  this.capabilities = ImmutableCapabilities.copyOf(Require.nonNull("Capabilities", capabilities));
  this.metadata = ImmutableMap.copyOf(Require.nonNull("Metadata", metadata));
}
 
Example 6
Source File: Session.java    From selenium with Apache License 2.0 5 votes vote down vote up
public Session(SessionId id, URI uri, Capabilities capabilities) {
  this.id = Require.nonNull("Session ID", id);
  this.uri = Require.nonNull("Where the session is running", uri);

  this.capabilities = ImmutableCapabilities.copyOf(
      Require.nonNull("Session capabilities", capabilities));
}
 
Example 7
Source File: OneShotNode.java    From selenium with Apache License 2.0 5 votes vote down vote up
private Capabilities rewriteCapabilities(RemoteWebDriver driver) {
  // Rewrite the se:options if necessary
  Object rawSeleniumOptions = driver.getCapabilities().getCapability("se:options");
  if (rawSeleniumOptions == null || rawSeleniumOptions instanceof Map) {
    @SuppressWarnings("unchecked") Map<String, Object> original = (Map<String, Object>) rawSeleniumOptions;
    Map<String, Object> updated = new TreeMap<>(original == null ? new HashMap<>() : original);

    String cdpPath = String.format("/session/%s/se/cdp", driver.getSessionId());
    updated.put("cdp", rewrite(cdpPath));

    return new PersistentCapabilities(driver.getCapabilities()).setCapability("se:options", updated);
  }

  return ImmutableCapabilities.copyOf(driver.getCapabilities());
}
 
Example 8
Source File: NodeStatus.java    From selenium with Apache License 2.0 4 votes vote down vote up
public Active(Capabilities stereotype, SessionId id, Capabilities currentCapabilities) {
  this.stereotype = ImmutableCapabilities.copyOf(Require.nonNull("Stereotype", stereotype));
  this.id = Require.nonNull("Session id", id);
  this.currentCapabilities =
      ImmutableCapabilities.copyOf(Require.nonNull("Capabilities", currentCapabilities));
}
 
Example 9
Source File: SessionSlot.java    From selenium with Apache License 2.0 4 votes vote down vote up
public SessionSlot(EventBus bus, Capabilities stereotype, SessionFactory factory) {
  this.bus = Require.nonNull("Event bus", bus);
  this.stereotype = ImmutableCapabilities.copyOf(Require.nonNull("Stereotype", stereotype));
  this.factory = Require.nonNull("Session factory", factory);
}