diff --git a/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java b/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java index 2ca612a23efe6..934f40661d546 100644 --- a/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java +++ b/java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java @@ -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; @@ -165,6 +166,7 @@ public Either apply(CreateSessionRequest sess } 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 webSocketUrl = + Optional.ofNullable((String) caps.getCapability("webSocketUrl")); + + Optional 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";