-
Notifications
You must be signed in to change notification settings - Fork 228
When calling waitUntilWindowLoaded, webContents is not set in Application #174
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
Comments
having related issues.. |
I am also having the same issue.
|
Having the same issue too. I'm using electron 1.6.11 and tried with both spectron 3.7.2 and 3.6.4, but the issue is the same. The code I run is the following: import { expect } from 'chai';
import { Application } from 'spectron';
const timeout = 10000;
describe('application launch', function () {
let app;
const startApp = function() {
app = new Application({
path: require('electron'),
args: ['src/init'],
startTimeout: timeout,
waitTimeout: timeout,
});
return app.start().then(setupApp);
};
const setupApp = function() {
return app.client.waitUntilWindowLoaded();
};
before(function() {
this.timeout(timeout);
return startApp();
});
after(function () {
if (app && app.isRunning()) {
return app.stop();
}
});
it('shows hello world text on screen after launch', function () {
return app.client.element('#title').then(function (text) {
expect(text).to.equal('Hello world');
});
});
}); If I skip the setupApp function, then {
message: "An element could not be located on the page using the given search parameters.",
selector: "#title",
sessionId: "aa61e928c97596416a08b4c89b51dea4",
state: "failure",
status: 7,
type: "NoSuchElement",
value: null
} This, given that my index.html only has a |
The problem persists using [email protected] |
I also tried using [email protected] and [email protected], which are the versions used by the electron-api-demos app. With these versions, Even though this step helps it going, I still receive the "an element could not be located..." error object. |
My last comment is true on windows, but on Ubuntu the issue persists even with those versions of electron and spectron. |
Having the same issue with 3.7.2 on Elementary OS Loki (Ubuntu 16.04 base). |
Same issue on MacOS with spectron 3.7.2 and electron 1.6.11. |
Oh, I found the problem. It's because I opened the devtool in the main script. After disabling it, it works well. |
@TooBug Confirmed that fixed my issue (I was loading devtools in my prod build also.) Thanks! |
@TooBug Thank you it save my day |
I had this issue too - perhaps we could add something to the README? |
This error can also occur if you set requireName to something and your app doesn't correspond properly. E.g. I had set requireName: 'electronRequire' but my app forgot to change window.electronRequire = require;
|
Hi, thanks in advance |
Closing as this seems to have been resolved. |
Is not resolved, I still have the problem |
according to electron-userland/spectron#174 (comment) this might help re error like in https://travis-ci.org/artemv/angular-electron-spectron/builds/500315009 ..but this also could be node version dependent as I don't have it locally on MacOS & Node 9
Using electron@5 you must set
This fixed my issue. |
The issue is still there in Electron 5.0.0 with Spectron 7.0.0: trying to access any of the app properties |
The issue is still present :( |
Report this issue if the libraries version is:
It's ok if the libraries version is:
It's ok if the libraries version is:
But if electron version is "5.0.0", then it will trigger an error like "TypeError: waitUntilWindowLoaded Cannot read property 'isLoading' of undefined" |
according to electron-userland/spectron#174 (comment) this might help re error like in https://travis-ci.org/artemv/angular-electron-spectron/builds/500315009 ..but this also could be node version dependent as I don't have it locally on MacOS & Node 9
It looks the issue is that webdriverio cannot see the main window if it was initialized ~50 ms after the app ready event. Here's the minimal reproducible example. // test.js
const electron = require('electron')
const { Application } = require('spectron')
const app = new Application({
args: ['<cwd>/app.js'],
path: electron,
})
Promise.resolve()
.then(() => app.startChromeDriver())
.then(() => app.createClient())
.then(() => {
return app.client
.execute(function (requireName) {
return typeof window[requireName] === 'function'
}, 'require')
.then(console.log)
})
// app.js
const { app, BrowserWindow } = require('electron')
app.on('ready', () => {
const w = new BrowserWindow()
setTimeout(() => {
w.loadURL('https://ya.ru')
}, 5000)
}) As a workaround, one can load the blank page immediately. This fixes the aforementioned issue for me. const { app, BrowserWindow } = require('electron')
app.on('ready', () => {
const w = new BrowserWindow()
w.loadURL('about:blank')
setTimeout(() => {
w.loadURL('https://ya.ru')
}, 5000)
}) |
Having the same issue here with main.js : `const { app, BrowserWindow } = require('electron') function createWindow () { const win = new BrowserWindow({ win.loadFile('index.html') //win.webContents.openDevTools() app.on('window-all-closed', () => { app.on('activate', () => { })` DevDependecies in package.json :
test script : `const { Application } = require('spectron') const myApp = new Application({ const verifyWindowIsVisibleWithTitle = async (app) => { Error is the same wether win.webContents.openDevTools() is commented or not : Test failed Cannot read property 'isVisible' of undefined |
I still have this issue |
Same issue with the following version {
"devDependencies": {
"electron": "13.1.7",
"electron-rebuild": "~2.3.5",
"spectron": "~15.0.0"
}
} My simple test file const assert = require('assert');
const path = require('path');
const electronPath = require('electron');
const { Application } = require('spectron');
const app = new Application({
path: electronPath,
env: {
NODE_ENV: 'test',
},
args: [path.join(__dirname, '..')],
webdriverOptions: {
deprecationWarnings: false,
},
});
app
.start()
.then(() => {
return app.client.waitUntilWindowLoaded(5000);
})
.then(async () => {
const visible = app.browserWindow.isVisible();
assert.strictEqual(visible, true);
})
.catch((error) => {
console.error('Test failed: ', error.message);
console.error(error);
}); |
according to electron-userland/spectron#174 (comment) this might help re error like in https://travis-ci.org/artemv/angular-electron-spectron/builds/500315009 ..but this also could be node version dependent as I don't have it locally on MacOS & Node 9
according to electron-userland/spectron#174 (comment) this might help re error like in https://travis-ci.org/artemv/angular-electron-spectron/builds/500315009 ..but this also could be node version dependent as I don't have it locally on MacOS & Node 9
according to electron-userland/spectron#174 (comment) this might help re error like in https://travis-ci.org/artemv/angular-electron-spectron/builds/500315009 ..but this also could be node version dependent as I don't have it locally on MacOS & Node 9
according to electron-userland/spectron#174 (comment) this might help re error like in https://travis-ci.org/artemv/angular-electron-spectron/builds/500315009 ..but this also could be node version dependent as I don't have it locally on MacOS & Node 9
according to electron-userland/spectron#174 (comment) this might help re error like in https://travis-ci.org/artemv/angular-electron-spectron/builds/500315009 ..but this also could be node version dependent as I don't have it locally on MacOS & Node 9
I'm seeing:
waitUntilWindowLoaded: Cannot read property 'isLoading' of undefined
This is the same issue as reported in issue 157, but that was closed, so I thought I would open a new issue.
See: #157
I am using spectron 3.4.0 with electron 1.3.2, but I also tried spectron 3.3.0 and this made no difference for me.
After running a lot of tests and debugging, I am pretty convinced the issue is related to the following:
It appears that things work fine as long as the electron App under test creates AND loads its window immediately upon call to the app ready event handler. However, if loading the window is deferred to perform some other processing first, the above error occurs consistently.
Just to be real clear here:
The following does not seem to have a problem:
However, the following always seems to fail:
The text was updated successfully, but these errors were encountered: