Cannot run tests on a Remote Selenium Grid
Hi, this was a similar issue I reported in the WebDriverIO project (which since has gotten resolved), and seems to occur in this project as well (reference: https://github.com/webdriverio/webdriverio/issues/13206). Coming from Karma, I used to be able to launch my tests in a remote selenium grid running on a separate machine. However, when trying this with WTR I get the following error:
Stack Trace / Run Output:
chrome: |██████████████████████████████| 0/1 test files | 0 passed, 0 failed
Running tests...
Running 1 test files...
2024-08-21T18:01:27.234Z ERROR webdriver: Request failed with status 500 due to unknown error: unknown error: net::ERR_CONNECTION_REFUSED
(Session info: chrome=127.0.6533.99)
dists/testFile.js:
❌ unknown error: net::ERR_CONNECTION_REFUSED
(Session info: chrome=127.0.6533.99)
unknown error: unknown error: net::ERR_CONNECTION_REFUSED
(Session info: chrome=127.0.6533.99)
at getErrorFromResponseBody (file://.../node_modules/webdriver/build/utils.js:195:12)
at NodeJSRequest._request (file://.../node_modules/webdriver/build/request/index.js:193:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Browser.wrapCommandFn (file://.../node_modules/@wdio/utils/build/shim.js:90:29)
at async IFrameManager._initialize (.../node_modules/@web/test-runner-webdriver/dist/IFrameManager.js:20:9)
at async IFrameManager.queueStartSession (.../node_modules/@web/test-runner-webdriver/dist/IFrameManager.js:62:13)
Here is my config file:
const wd = require('@web/test-runner-webdriver')
module.exports = {
files: 'dists/testFile.js',
nodeResolve: true,
browsers: [
wd.webdriverLauncher({
automationProtocol: 'webdriver',
hostname: 'company.grid.com',
port: 4444,
protocol: 'http',
path: '/',
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: [
'--auto-open-devtools-for-tabs',
'--use-fake-ui-for-media-stream',
'--use-fake-device-for-media-stream',
'--disable-infobars',
'--disable-translate',
'--ignore-certificate-errors',
'--no-sandbox'
]
}
}
})
],
testFramework: {
config: {
ui: 'bdd',
timeout: '120000'
}
}
}
The above config works when I don't specify the hostname, port, protocol, and path.
In WDIO case, it was a matter of the Vite config not taking in the user's specified server options for hosting the served test files. I didn't see anything in the WTR which would allow me to serve the test files on a non-localhost ip. Since we are launching the test in a remote selenium grid, it would need to access an https+IP and not localhost.
I tried using the following which I see specified here, but it didn't work:
// configuration for the server
protocol?: string;
hostname?: string;
port?: number;
Maybe it's something I can do with this configuration? server?: Server;. Although, not sure what Server entails.