Skip to content

Commit 2de324b

Browse files
authored
Merge branch 'trunk' into bidi-chromium
2 parents a0a0bf3 + d97e441 commit 2de324b

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

java/src/org/openqa/selenium/bidi/BiDiProvider.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ public HasBiDi getImplementation(Capabilities caps, ExecuteMethod executeMethod)
5555
}
5656

5757
private Optional<URI> getBiDiUrl(Capabilities caps) {
58-
Optional<String> webSocketUrl =
59-
Optional.ofNullable((String) caps.getCapability("webSocketUrl"));
58+
Object bidiCapability;
59+
if (caps.asMap().containsKey("se:bidi")) {
60+
// Session is created remotely
61+
bidiCapability = caps.getCapability("se:bidi");
62+
} else {
63+
bidiCapability = caps.getCapability("webSocketUrl");
64+
}
65+
Optional<String> webSocketUrl = Optional.ofNullable((String) bidiCapability);
6066

6167
return webSocketUrl.map(
6268
uri -> {

java/src/org/openqa/selenium/firefox/FirefoxDriver.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,16 @@ public Optional<BiDi> maybeGetBiDi() {
348348
return biDi;
349349
}
350350

351+
@Override
352+
public BiDi getBiDi() {
353+
if (!biDiUri.isPresent()) {
354+
throw new BiDiException("This version of Firefox or geckodriver does not support Bidi");
355+
}
356+
357+
return maybeGetBiDi()
358+
.orElseThrow(() -> new DevToolsException("Unable to initialize Bidi connection"));
359+
}
360+
351361
@Override
352362
public void quit() {
353363
super.quit();

java/src/org/openqa/selenium/grid/node/ProxyNodeWebsockets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public Optional<Consumer<Message>> apply(String uri, Consumer<Message> downstrea
6969
UrlTemplate.Match bidiMatch = BIDI_TEMPLATE.match(uri);
7070
UrlTemplate.Match vncMatch = VNC_TEMPLATE.match(uri);
7171

72-
if (cdpMatch == null && vncMatch == null && fwdMatch == null) {
72+
if (bidiMatch == null && cdpMatch == null && vncMatch == null && fwdMatch == null) {
7373
return Optional.empty();
7474
}
7575

java/src/org/openqa/selenium/grid/node/local/LocalNode.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,10 @@ public Either<WebDriverException, CreateSessionResponse> newSession(
495495
desiredCapabilities);
496496

497497
String sessionCreatedMessage = "Session created by the Node";
498-
LOG.info(String.format("%s. Id: %s, Caps: %s", sessionCreatedMessage, sessionId, caps));
498+
LOG.info(
499+
String.format(
500+
"%s. Id: %s, Caps: %s",
501+
sessionCreatedMessage, sessionId, externalSession.getCapabilities()));
499502

500503
return Either.right(
501504
new CreateSessionResponse(
@@ -533,6 +536,8 @@ private Capabilities setDownloadsDirectory(UUID uuid, Capabilities caps) {
533536
"download.prompt_for_download",
534537
false,
535538
"download.default_directory",
539+
tempDir.getAbsolutePath(),
540+
"savefile.default_directory",
536541
tempDir.getAbsolutePath());
537542
String optionsKey = Browser.CHROME.is(caps) ? "goog:chromeOptions" : "ms:edgeOptions";
538543
return appendPrefs(caps, optionsKey, map);

0 commit comments

Comments
 (0)