Have you read the Contributing Guidelines on issues?
WebdriverIO Version
9.27.0
Node.js Version
22.21.1
Mode
WDIO Testrunner
Which capabilities are you using?
{
"bstack:options": {
os: "Windows",
osVersion: "11",
seleniumVersion: "4.40.0",
seleniumBidi: "true",
// ...other bstack options
},
browserName: "chrome",
browserVersion: "latest",
}
What happened?
This is a follow-up to #14922, which was closed after a fix was merged in v9.22.0 but subsequently reverted in commit 6edc9c7 (Jan 17, 2026) because the fix caused issues elsewhere. The issue was never reopened, and the bug persists in v9.27.0.
When seleniumBidi: "true" is set in BrowserStack capabilities and testObservability is enabled (the default), @wdio/browserstack-service calls:
browser.execute(browserstack_executor: ${JSON.stringify({
action: 'annotate',
arguments: { data: ObservabilitySync:${Date.now()}, level: 'debug' }
})})
With classic WebDriver, browser.execute() sends this string via HTTP to BrowserStack's hub, which intercepts browserstack_executor: as a special command before it ever reaches the browser.
With BiDi enabled, browser.execute() uses script.evaluate over WebSocket directly to the browser, which tries to parse the string as JavaScript. browserstack_executor: {...} is not valid JavaScript, resulting in:
SyntaxError: Unexpected token ':'
at new Function ()
at Browser.execute (node_modules/webdriverio/build/node.js:3685:53)
at async performO11ySync (node_modules/@wdio/browserstack-service/build/index.js:4088:9)
This affects both Chrome and Edge with BiDi enabled.
What is your expected behavior?
@wdio/browserstack-service should detect when a session is using BiDi and route browserstack_executor commands through the classic WebDriver HTTP endpoint instead of browser.execute(), or use an alternative mechanism that doesn't rely on executing non-JavaScript strings in the browser context. The only current workaround is testObservability: false in the browserstack service config, which disables observability features entirely.
How to reproduce the bug.
- Configure any test with seleniumBidi: "true" in bstack:options
- Use @wdio/browserstack-service with default settings (testObservability is true by default)
- Run any test spec
Relevant log output
[0-0] <anonymous_script>:3
[0-0] browserstack_executor: {"action":"annotate","arguments":{"data":"ObservabilitySync:1776843280286","level":"debug"}}
[0-0] ^
[0-0] SyntaxError: Unexpected token ':'
[0-0] at new Function (<anonymous>)
[0-0] at Browser.execute (node_modules/webdriverio/build/node.js:3685:53)
[0-0] at async performO11ySync (node_modules/@wdio/browserstack-service/build/index.js:4088:9)
Code of Conduct
Is there an existing issue for this?
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
9.27.0
Node.js Version
22.21.1
Mode
WDIO Testrunner
Which capabilities are you using?
What happened?
This is a follow-up to #14922, which was closed after a fix was merged in v9.22.0 but subsequently reverted in commit 6edc9c7 (Jan 17, 2026) because the fix caused issues elsewhere. The issue was never reopened, and the bug persists in v9.27.0.
When seleniumBidi: "true" is set in BrowserStack capabilities and testObservability is enabled (the default), @wdio/browserstack-service calls:
browser.execute(browserstack_executor: ${JSON.stringify({action: 'annotate',
arguments: { data:
ObservabilitySync:${Date.now()}, level: 'debug' }})}
)With classic WebDriver, browser.execute() sends this string via HTTP to BrowserStack's hub, which intercepts browserstack_executor: as a special command before it ever reaches the browser.
With BiDi enabled, browser.execute() uses script.evaluate over WebSocket directly to the browser, which tries to parse the string as JavaScript. browserstack_executor: {...} is not valid JavaScript, resulting in:
This affects both Chrome and Edge with BiDi enabled.
What is your expected behavior?
@wdio/browserstack-service should detect when a session is using BiDi and route browserstack_executor commands through the classic WebDriver HTTP endpoint instead of browser.execute(), or use an alternative mechanism that doesn't rely on executing non-JavaScript strings in the browser context. The only current workaround is testObservability: false in the browserstack service config, which disables observability features entirely.
How to reproduce the bug.
Relevant log output
Code of Conduct
Is there an existing issue for this?