-
Notifications
You must be signed in to change notification settings - Fork 228
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
javascript error: Cannot convert undefined or null to object #720
Comments
correct me if I'm wrong but might this webdriverio/webdriverio#5370 be the issue? We're using |
Same issue here with I've been struggling to get it integrated into my electron app for the first time. I was hitting errors like
Then I addd javascript error: javascript error: Cannot convert undefined or null to object
(Session info: chrome=85.0.4183.98)
at getErrorFromResponseBody (node_modules/webdriver/build/utils.js:121:10)
at WebDriverRequest._request (node_modules/webdriver/build/request.js:149:56)
at Browser.wrapCommandFn (node_modules/@wdio/utils/build/shim.js:74:23)
at Browser.wrapCommandFn (node_modules/@wdio/utils/build/shim.js:74:23) |
@pgalle Is there a reason Spectron cannot just upgrade to the latest I don't see any breaking changes between |
Actually, Spectron has
Also, WebdriverIO merged the PR fixing webdriverio/webdriverio#5370 in v6.1.9, so we've got the patch either way. Any other ideas? |
Same issue here, with |
I tired to rip my project to it's basest hello world example. All I have left is React, Typescript, Electron and Spectron. It still fails, but it is the base playground. https://github.com/TheOne20001/electron-react-typescript-spectron |
I have the exact same errors and package versions as @VictorFouquet. Do we know what set of versions currently work? |
@michlimlim though it doesn't solve the actual problem, I've downgraded my project to |
I tried the above versions from VictorFouquet with no luck - still seeing the above error. |
It does work to downgrade but that is no solution, its just avoiding the problem.
as per yours, do you have the two fixes 174, and 254 that i mentioned above? |
It's not entirely clear what the "fixes" above are. I have in my BrowserWindow ctor the following options
Are the fixes something different? |
so one of them is to close your devtools window/panel when you are not in dev mode, because that can throw things off, the other is a delay on loading contents into your window by way of a timeout around your loadUrl call. However as I have said these seem to only help in electron versions <= 9. |
That's funny - I read it as the solution is to load your contents right away without a timeout around your loadUrl call. My code had no wait to load - it loaded immediately. With the above fixes on the old version I am back in shape. |
From the pattern i'd say those two are work arounds and no the actual fixes, but something in 10 disrupts them and brings the actual errors back to the fore. I hope someone does figure out what the actual error is. I'm surprised Spectron folks aren't seeing these issues, and we are... |
First time I try to use Spectron - and using the readme example - I do get the same error as others have mentionned:
|
Same issue here.
EDIT: macOS 10.15.7 |
Here is a minimal reproducible example: package.json{
"main": "main.js",
"dependencies": {
"electron": "^10.1.5",
"spectron": "^12.0.0",
"mocha": "^8.2.0"
}
} main.jsconst {app, BrowserWindow} = require('electron');
app.on('ready', () => {
const mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true
}
});
mainWindow.loadFile('about:blank');
});
app.on('window-all-closed', function () {
app.quit();
}); spec.js
To Run:
Error (shown in terminal)
Full error from Object.getErrorFromResponseBody (node_modules\webdriver\build\utils.js:94:12)
|
Any updates on this? Or workarounds for now? |
Any updates on this? |
Tracked this one down I think. Its an error from https://github.com/electron-userland/spectron/blob/1510a9beddb64ca3630c143ccdc15466e17b40f5/lib/api.js whose stack trace gets eaton by the bootstrap process. Running it manually, we find the error is thrown here because Line 141 in 1510a9b
As of Electron 10 The fix for me was to explicitly enable it when creating my window in const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
},
}); This should be updated in the getting started docs, and Spectron should migrate away from electron.remote if that's not already planned 🙂 |
This didn't solve it for me - I actually already tried this a few months ago. |
@amiller-gh This is correct. Remote module was missing. I enable it during tests now. |
Hey, after updating
electron
to v10 andspectron
to v12 I've started having issues with running my test suite. So I started debugging by creating a single test with code taken from spectron's readme. And when trying to run this test (I'm using Jest by the way) I get this error:Application window launches however, the test fails
The text was updated successfully, but these errors were encountered: