[grid] Add BiDi endpoint to returned caps if available
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;
@@ -165,6 +166,7 @@ public boolean test(Capabilities capabilities) {
}
caps = readDevToolsEndpointAndVersion(caps);
+ caps = readBiDiEndpoint(caps);
caps = readVncEndpoint(capabilities, caps);
span.addEvent("Driver service created session", attributeMap);
@@ -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";
