Skip to content

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

Open
wants to merge 2 commits into
base: 3.x
Choose a base branch
from

Conversation

ngraf
Copy link
Contributor

@ngraf ngraf commented Aug 22, 2025

…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:

  • I use "WebDriver" against Selenoid
  • Selenoid does not support Bidi protocol, because of reasons
  • Since Bidi protocol active became the new default behavior in CodeceptJS recently, my tests time out when executed against Selenoid 😕
  • Applying workaround "bidiProtocol" : "false" in WebDriver helper enables me to still run my test against Selenoid 🙂

Problem:

  • BUT, you always see this annoying error in STDOUT and you don't have the power to prevent it: 😕
    ❌ "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."
image

Solution presented in the pull-request:

  • before
await this.browser.sessionSubscribe({ events: ['log.entryAdded'] })
  • after
    // Check for Bidi, because "sessionSubscribe" is an exclusive Bidi protocol feature. Otherwise, error will be thrown.
    if (this.browser.capabilities && this.browser.capabilities.webSocketUrl) {
      await this.browser.sessionSubscribe({ events: ['log.entryAdded'] })
    }

Applicable helpers:

  • Playwright
  • Puppeteer
  • WebDriver
  • REST
  • FileHelper
  • Appium
  • TestCafe

Type of change

  • 🔥 Breaking changes
  • 🚀 New functionality
  • 🐛 Bug fix
  • 🧹 Chore
  • 📋 Documentation changes/updates
  • ♨️ Hot fix
  • 🔨 Markdown files fix - not related to source code
  • 💅 Polish code

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

Norbert Graf added 2 commits August 22, 2025 17:37
…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.
@kobenguyent kobenguyent requested a review from Copilot August 23, 2025 04:30
Copy link
Contributor

@Copilot Copilot AI left a 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.

Comment on lines +635 to 638
}

this.browser.on('log.entryAdded', logEvents)

Copy link
Preview

Copilot AI Aug 23, 2025

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.

Suggested change
}
this.browser.on('log.entryAdded', logEvents)
this.browser.on('log.entryAdded', logEvents)
}

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant