-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
9.16.2
Node.js Version
22.16.0
Mode
Standalone Mode
Which capabilities are you using?
{
"acceptInsecureCerts": true,
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
"--window-size=1800,1500",
"--disable-gpu",
"--no-sandbox",
"--disable-dev-shm-usage",
"--disable-extensions",
"--dns-prefetch-disable",
"--disable-browser-side-navigation",
"--disable-features=VizDisplayCompositor"
]},
"thirdparty:options": {
"networkLogs": true,
"idleTimeout": 150,
"os": "Windows",
"osVersion": "11",
"browserVersion": "latest-1",
"seleniumBidi": true,
"seleniumVersion": "4.29.0"
},
"wdio:maxInstances": 1,
"wdio:enforceWebDriverClassic": false,
"pageLoadStrategy": "eager",
"webSocketUrl": true
}What happened?
When trying to connect to a third party selenium provider from behind a corporate proxy, we are consistently getting the error Setting url options is only supported when automating browser using WebDriver Bidi protocol from here which was weird because we were using/enabling BiDi...
But we also saw the error log Could not connect to Bidi protocol of any candidate url in time: "wss://..." from here which lead us to think it was a proxy issue.
Digging through the code, we found that the websocket connection was timing out here, leading to this error. When we manually added the proxy we needed to this line through the options using a spread operator everything started to work again:
import { HttpsProxyAgent } from "https-proxy-agent";
// ...
const addedOptions = { ...options, agent: new HttpsProxyAgent(process.env.HTTP_PROXY) };
const ws2 = new WebSocket(candidateUrl, addedOptions);So the question is, would changing the code to do this be your recommended way to include a proxy for a websocket when needed? Or do you have a better way to include the required proxy to use BiDi with a third party from behind a corporate proxy?
What is your expected behavior?
Websocket connectivity to BrowserStack, or any third party, from behind a corporate proxy should use a proxy or agent, same as the HTTP(S) requests do.
How to reproduce the bug.
To fix the bug, change this line through the options using a spread operator and everything works:
import { HttpsProxyAgent } from "https-proxy-agent";
// ...
const addedOptions = { ...options, agent: new HttpsProxyAgent(process.env.HTTP_PROXY) };
const ws2 = new WebSocket(candidateUrl, addedOptions);(for us at least)
Relevant log output
...
[0-0] 2025-07-08T16:41:24.304Z INFO webdriver: Register BiDi handler for session with id xxxxx
[0-0] 2025-07-08T16:41:24.305Z INFO webdriver: Connecting to webSocketUrl wss://third-party.com:443/session/xxxx/se/bidi
[0-0] 2025-07-08T16:41:24.320Z DEBUG webdriver: Attempt to connect to webSocketUrl wss://third-party.com:443/session/xxxx/se/bidi
[0-0] 2025-07-08T16:41:34.324Z ERROR webdriver: Could not connect to Bidi protocol of any candidate url in time: "wss://third-party.com:443/session/xxxx/se/bidi"
...Code of Conduct
- I agree to follow this project's Code of Conduct
Is there an existing issue for this?
- I have searched the existing issues