|
49 | 49 | import org.openqa.selenium.remote.tracing.Tracer;
|
50 | 50 |
|
51 | 51 | import java.net.URI;
|
| 52 | +import java.net.URISyntaxException; |
52 | 53 | import java.net.URL;
|
53 | 54 | import java.time.Duration;
|
54 | 55 | import java.time.Instant;
|
@@ -165,6 +166,7 @@ public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sess
|
165 | 166 | }
|
166 | 167 |
|
167 | 168 | caps = readDevToolsEndpointAndVersion(caps);
|
| 169 | + caps = readBiDiEndpoint(caps); |
168 | 170 | caps = readVncEndpoint(capabilities, caps);
|
169 | 171 |
|
170 | 172 | span.addEvent("Driver service created session", attributeMap);
|
@@ -254,6 +256,28 @@ public DevToolsInfo(URI cdpEndpoint, String version) {
|
254 | 256 | return caps;
|
255 | 257 | }
|
256 | 258 |
|
| 259 | + private Capabilities readBiDiEndpoint(Capabilities caps) { |
| 260 | + |
| 261 | + Optional<String> webSocketUrl = |
| 262 | + Optional.ofNullable((String) caps.getCapability("webSocketUrl")); |
| 263 | + |
| 264 | + Optional<URI> websocketUri = webSocketUrl.map(uri -> { |
| 265 | + try { |
| 266 | + return new URI(uri); |
| 267 | + } catch (URISyntaxException e) { |
| 268 | + LOG.warning(e.getMessage()); |
| 269 | + } |
| 270 | + return null; |
| 271 | + }); |
| 272 | + |
| 273 | + if (websocketUri.isPresent()) { |
| 274 | + return new PersistentCapabilities(caps) |
| 275 | + .setCapability("se:bidi", websocketUri.get()); |
| 276 | + } |
| 277 | + |
| 278 | + return caps; |
| 279 | + } |
| 280 | + |
257 | 281 | private Capabilities readVncEndpoint(Capabilities requestedCaps, Capabilities returnedCaps) {
|
258 | 282 | String seVncEnabledCap = "se:vncEnabled";
|
259 | 283 | String seNoVncPortCap = "se:noVncPort";
|
|
0 commit comments