Skip to content

Commit

Permalink
[grid] Add BiDi endpoint to returned caps if available
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Oct 13, 2022
1 parent 07d52d4 commit bc438d4
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.openqa.selenium.remote.tracing.Tracer;

import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.Duration;
import java.time.Instant;
Expand Down Expand Up @@ -165,6 +166,7 @@ public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sess
}

caps = readDevToolsEndpointAndVersion(caps);
caps = readBiDiEndpoint(caps);
caps = readVncEndpoint(capabilities, caps);

span.addEvent("Driver service created session", attributeMap);
Expand Down Expand Up @@ -254,6 +256,28 @@ public DevToolsInfo(URI cdpEndpoint, String version) {
return caps;
}

private Capabilities readBiDiEndpoint(Capabilities caps) {

Optional<String> webSocketUrl =
Optional.ofNullable((String) caps.getCapability("webSocketUrl"));

Optional<URI> websocketUri = webSocketUrl.map(uri -> {
try {
return new URI(uri);
} catch (URISyntaxException e) {
LOG.warning(e.getMessage());
}
return null;
});

if (websocketUri.isPresent()) {
return new PersistentCapabilities(caps)
.setCapability("se:bidi", websocketUri.get());
}

return caps;
}

private Capabilities readVncEndpoint(Capabilities requestedCaps, Capabilities returnedCaps) {
String seVncEnabledCap = "se:vncEnabled";
String seNoVncPortCap = "se:noVncPort";
Expand Down

0 comments on commit bc438d4

Please sign in to comment.