webdriverio
webdriverio copied to clipboard
[🐛 Bug]: cannot read property 'selenoid:options' of undefined - during watch mode
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
WebdriverIO Version
latest
Node.js Version
14.17.5
Mode
Standalone Mode
Which capabilities are you using?
{
browserName: 'chrome',
acceptInsecureCerts: true
}
What happened?
Using the mock
api during watch
mode will work fine during the first run but will trigger the following error the second time :
[chrome (unknown) #0-0] Cannot read property 'selenoid:options' of undefined
[chrome (unknown) #0-0] TypeError: Cannot read property 'selenoid:options' of undefined
[chrome (unknown) #0-0] at Browser.getPuppeteer (/Users/test/app-test/node_modules/webdriverio/build/commands/browser/getPuppeteer.js:71:52)
[chrome (unknown) #0-0] at Browser.wrapCommandFn (/Users/test/app-test/node_modules/@wdio/utils/build/shim.js:131:38)
[chrome (unknown) #0-0] at async Browser.mock (/Users/test/app-test/node_modules/webdriverio/build/commands/browser/mock.js:119:9)
[chrome (unknown) #0-0] at async Browser.wrapCommandFn (/Users/test/app-test/node_modules/@wdio/utils/build/shim.js:131:29)
This seems related to https://github.com/webdriverio/webdriverio/issues/7086
What is your expected behavior?
No response
How to reproduce the bug.
Simply use a basic mock example (as from the doc):
it('should modify http responses', async () => {
const mock = await browser.mock('http://localhost:4200')
mock.respond('test');
});
Then:
- Start your test in watch mode
wdio run wdio.config.ts --watch
- Wait for the test to run
=> result: passing !
- Save your test file to trigger a new test run
=> result: cannot read property 'selenoid:options' of undefined
Relevant log output
[chrome (unknown) #0-0] Cannot read property 'selenoid:options' of undefined
[chrome (unknown) #0-0] TypeError: Cannot read property 'selenoid:options' of undefined
[chrome (unknown) #0-0] at Browser.getPuppeteer (/Users/test/app-test/node_modules/webdriverio/build/commands/browser/getPuppeteer.js:71:52)
[chrome (unknown) #0-0] at Browser.wrapCommandFn (/Users/test/app-test/node_modules/@wdio/utils/build/shim.js:131:38)
[chrome (unknown) #0-0] at async Browser.mock (/Users/test/app-test/node_modules/webdriverio/build/commands/browser/mock.js:119:9)
[chrome (unknown) #0-0] at async Browser.wrapCommandFn (/Users/test/app-test/node_modules/@wdio/utils/build/shim.js:131:29)
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Is there an existing issue for this?
- [X] I have searched the existing issues
Thanks for reporting!
It seems that we don't correctly pass in the arguments when we rerun a session. My first guess is in watcher.ts
but not entirely sure.
Any contributions that resolves the bug are highly appreciated. Please take a look into our contribution guidelines and let us know if you have any questions. Cheers!
I think so, because when the method getPuppeteer.ts#L45 is called:
The first time
Both capabilities
and requestedCapabilities
are properly set.

The second time
Most of the previous info are lost.

I would be glad to help, as always, but unfortunately after further investigation I think it requires more knowledge of the library than I have..
Could this be related to #7086 ?
I can still repro this right now with Chrome 100.
@ari-meetai any contribution that helps fixing the issue is welcome!
@ari-meetai, yes I think so (that's what I said in the What happened? section)
@ari-meetai, are you still facing this issue ?
Because I don't know what fixed it, but I got it working with the following configuration:
"@wdio/cli": "^7.19.5",
"@wdio/jasmine-framework": "^7.19.5",
"@wdio/local-runner": "^7.19.5",
"@wdio/spec-reporter": "^7.19.5",
"chromedriver": "^100.0.0",
I will close this due to inactivity. We've done various further improvements to the watch mode so if this bug still seems to be valid I am happy to re-open.
I'm experiencing the same issue when trying to mock API calls in component tests.
TypeError: Cannot read properties of undefined (reading 'selenoid:options')
at Browser.getPuppeteer (http://localhost:52696/node_modules/@wdio/browser-runner/node_modules/webdriverio/build/commands/browser/getPuppeteer.js?v=7bf5bdff:67:52)
at Browser.wrapCommandFn (http://localhost:52696/node_modules/@wdio/utils/build/shim.js?v=7bf5bdff:88:38)
at Browser.<anonymous> (http://localhost:52696/node_modules/@wdio/utils/build/shim.js?v=7bf5bdff:240:24)
at Browser.mock (http://localhost:52696/node_modules/@wdio/browser-runner/node_modules/webdriverio/build/commands/browser/mock.js?v=7bf5bdff:115:20)
at Browser.wrapCommandFn (http://localhost:52696/node_modules/@wdio/utils/build/shim.js?v=7bf5bdff:88:38)
at Browser.mock (http://localhost:52696/node_modules/@wdio/utils/build/shim.js?v=7bf5bdff:240:24)
at Context.<anonymous> (http://localhost:52696/Users/[redacted]:96:45)
The line of code that is breaking is when I call browser.mock
const apiPOSTMock = await browser.mock("**/api", {
method: "post",
});
I tried to set selenoid:options
in the capabilities object in wdio.conf.ts
, but that doesn't work
capabilities: [
{
// capabilities for local browser web tests
browserName: "chrome", // or "firefox", "microsoftedge", "safari"
"selenoid:options": {
enableVNC: true,
enableVideo: true,
},
"moon:options":{}
},
],
I've attached my wdio config file and package json below for additional context. Any advice would be appreciated. configs.zip
@kenchen-asurion can you raise a new issue titled: "Support mock
command for browser-runner"? This capability is not yet enabled when running tests within the browser. We definitely want to make this experience seamless now that the command will allow mocking cross browser at some day.
In the meantime I recommend to mock the complete fetch
command from the global window scope.
Thanks for the quick response. I have opened a new issue for this.