-
-
Notifications
You must be signed in to change notification settings - Fork 747
bugfix: prevent this error when running WebDriver without Bidi protocol: 'Error: Failed to execute WebDriver Bidi command "sessionSubscribe"' #5095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.x
Are you sure you want to change the base?
Conversation
…d "sessionSubscribe" as no Bidi session was established. Make sure you enable it by setting "webSocketUrl: true" in your capabilities and verify that your environment and browser supports it.' being printed to stdout when user deactivated Bidi protocol with "bidiProtocol" : false in Webdriver config.
…d "sessionSubscribe" as no Bidi session was established. Make sure you enable it by setting "webSocketUrl: true" in your capabilities and verify that your environment and browser supports it.' being printed to stdout when user deactivated Bidi protocol with "bidiProtocol" : false in Webdriver config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an error that occurs when running WebDriver without the Bidi protocol enabled. The fix prevents the error message about failed "sessionSubscribe" command from being printed when users explicitly disable Bidi protocol support.
- Adds conditional check before calling
sessionSubscribe
to only execute when Bidi protocol is enabled - Updates comment to reflect that Bidi protocol default is now true
- Prevents error output when using
"bidiProtocol": false
configuration with environments that don't support Bidi
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
lib/helper/WebDriver.js
Outdated
} | ||
|
||
this.browser.on('log.entryAdded', logEvents) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event listener for 'log.entryAdded' is being registered regardless of whether Bidi protocol is enabled, but the corresponding sessionSubscribe call that enables these events is now conditional. This will result in the event listener never being triggered when Bidi is disabled, creating dead code.
} | |
this.browser.on('log.entryAdded', logEvents) | |
this.browser.on('log.entryAdded', logEvents) | |
} |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ngraf may you advise this please? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point from Copilot.
I made an additional commit and moved
"this.browser.on('log.entryAdded', logEvents)" into the "if" condition:
if (this.browser.capabilities && this.browser.capabilities.webSocketUrl) {
await this.browser.sessionSubscribe({ events: ['log.entryAdded'] })
this.browser.on('log.entryAdded', logEvents)
}
@kobenguyent , what is actually the downpart of not having the browser logs added?
Will it break some essential functionality? Or is it just a bonus feature?
I mean, as of today the feature does not work for "bidiProtocol: false" anyway. I wonder if this fact needs to be documented in the documentation that the feature of tracking browser logs is only supported when "bidiProtocol" is true. Alternatively the feature to collect logs could be rewritten in a way, so that the feature works for "bidiProtocol" false and true. But I guess it may be hard to impossible to collect logs without "bidiProtocol" enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unit test failed. Isn a flaky test failing. At least the failing unit test is about some timing and wait mechanism. I don't really see a relationship to my tiny changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point from Copilot.
I made an additional commit and moved "this.browser.on('log.entryAdded', logEvents)" into the "if" condition:
if (this.browser.capabilities && this.browser.capabilities.webSocketUrl) { await this.browser.sessionSubscribe({ events: ['log.entryAdded'] }) this.browser.on('log.entryAdded', logEvents) }
@kobenguyent , what is actually the downpart of not having the browser logs added? Will it break some essential functionality? Or is it just a bonus feature? I mean, as of today the feature does not work for "bidiProtocol: false" anyway. I wonder if this fact needs to be documented in the documentation that the feature of tracking browser logs is only supported when "bidiProtocol" is true. Alternatively the feature to collect logs could be rewritten in a way, so that the feature works for "bidiProtocol" false and true. But I guess it may be hard to impossible to collect logs without "bidiProtocol" enabled.
imho, the current implementation is quite basic and only handles log events.
…d "sessionSubscribe" as no Bidi session was established. Make sure you enable it by setting "webSocketUrl: true" in your capabilities and verify that your environment and browser supports it.' being printed to stdout when user deactivated Bidi protocol with "bidiProtocol" : false in Webdriver config.
…d "sessionSubscribe" as no Bidi session was established. Make sure you enable it by setting "webSocketUrl: true" in your capabilities and verify that your environment and browser supports it.' being printed to stdout when user deactivated Bidi protocol with "bidiProtocol" : false in Webdriver config.
Motivation/Description of the PR
Situation:
Problem:
❌ "Error: Failed to execute WebDriver Bidi command "sessionSubscribe" as no Bidi session was established. Make sure you enable it by setting "webSocketUrl: true" in your capabilities and verify that your environment and browser supports it."
Solution presented in the pull-request:
Applicable helpers:
Type of change
Checklist:
npm run docs
)npm run lint
)npm test
)