question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When calling waitUntilWindowLoaded, webContents is not set in Application

See original GitHub issue

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: https://github.com/electron/spectron/issues/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:

let mainWindow

app.on('ready', () => {
    mainWindow = new BrowserWindow({ 
        width: 1400, 
        height: 900,
        backgroundColor: '#EAECEE'
    })
    mainWindow.loadURL(`file://${__dirname}/index.html`)
})

However, the following always seems to fail:

let mainWindow

app.on('ready', () => {
    mainWindow = new BrowserWindow({ 
        width: 1400, 
        height: 900,
        backgroundColor: '#EAECEE'
    })
    setTimeout(() => {
        mainWindow.loadURL(`file://${__dirname}/index.html`)
    }, 2000)
})

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:26 (1 by maintainers)

github_iconTop GitHub Comments

31reactions
TooBugcommented, Aug 1, 2017

Oh, I found the problem. It’s because I opened the devtool in the main script. After disabling it, it works well.

6reactions
josiahruddellcommented, Aug 28, 2019

Using electron@5 you must set

webPreferences: {
  nodeIntegration: true,
},

This fixed my issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A brand new website interface for an even better experience!
When calling waitUntilWindowLoaded, webContents is not set in Application.
Read more >
simple example of electron app with spectron test
I am getting the error " TypeError: Cannot read property 'waitUntilWindowLoaded' of undefined" when I run the test. Also when looking at the ......
Read more >
spectron | Yarn - Package Manager
Easily test your Electron apps using ChromeDriver and WebdriverIO. electron, chromedriver, webdriverio, selenium. readme. Spectron icon Spectron. CI js- ...
Read more >
Chapter 13. Testing applications with Spectron - Electron in ...
Testing the initial state of the UI: ./test/spec.js. it('should not have clippings when it starts up', async () => { await app.client.waitUntilWindowLoaded(); # ......
Read more >
BrowserWindow | Electron
Emitted when the window is set or unset to show always on top of other windows. Event: 'app-command' Windows Linux​. Returns: event Event;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found