Skip to content

Commit b004ca8

Browse files
authored
bugfix: prevent this error when running WebDriver without Bidi protocol: 'Error: Failed to execute WebDriver Bidi command "sessionSubscribe"' (#5095)
1 parent 5c38989 commit b004ca8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/helper/WebDriver.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ class WebDriver extends Helper {
491491
}
492492
config.capabilities.browserName = config.browser || config.capabilities.browserName
493493

494-
// WebDriver Bidi Protocol. Default: false
494+
// WebDriver Bidi Protocol. Default: true
495495
config.capabilities.webSocketUrl = config.bidiProtocol ?? config.capabilities.webSocketUrl ?? true
496496

497497
config.capabilities.browserVersion = config.browserVersion || config.capabilities.browserVersion
@@ -629,8 +629,11 @@ class WebDriver extends Helper {
629629

630630
this.browser.on('dialog', () => {})
631631

632-
await this.browser.sessionSubscribe({ events: ['log.entryAdded'] })
633-
this.browser.on('log.entryAdded', logEvents)
632+
// Check for Bidi, because "sessionSubscribe" is an exclusive Bidi protocol feature. Otherwise, error will be thrown.
633+
if (this.browser.capabilities && this.browser.capabilities.webSocketUrl) {
634+
await this.browser.sessionSubscribe({ events: ['log.entryAdded'] })
635+
this.browser.on('log.entryAdded', logEvents)
636+
}
634637

635638
return this.browser
636639
}

0 commit comments

Comments
 (0)