Skip to content
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

Error : TypeError: waitUntilWindowLoaded Cannot read property 'isLoading' of undefined when calling app.client.waitUntilWindowLoaded() #570

Closed
BabuShoban opened this issue Mar 27, 2020 · 4 comments

Comments

@BabuShoban
Copy link

BabuShoban commented Mar 27, 2020

I am using electron version "6.1.9" and spectron "8.0.0" , node integration in my electron app is set to "true"

I am rendering a website inside "webview" tag and I want to test some component on the web site which is inside "webview" tag

When I run app.client.getwindowcount() , I see it returning window count as 2. Below is the code snippet which is failing.

Code Snippet:

await app.client.windowByIndex(1) await app.client.waitUntilWindowLoaded()

Below are the web preferences set inside my electron application:

webPreferences: { nativeWindowOpen: false, nodeIntegration: true, contextIsolation: true, webviewTag: true, enableRemoteModule: false, preload: path.join(__dirname, ".//", "preload.js") }

Please help me with this issue.

@sarathms
Copy link

Getting started with Spectron, this was one of the many things that frustrated me. I don't recall which one solved this particular problem, but you may try these:

  1. Make sure you avoid opening devTools. I use cross-env NODE_env=test mocha in package.json and then use it in main.js to skip opening devTools and extensions.

  2. If you are developing on Linux, run this command once per desktop session. This seems to be needed for newer versions of electron

sudo sysctl kernel.unprivileged_userns_clone=1

@BabuShoban
Copy link
Author

@sarathms Thanks for taking time to reply on this issue.

The above solution will not work for me as I have not added code to open dev tools or extensions. Also, I am running the test on windows OS.

@pcawen
Copy link

pcawen commented Apr 9, 2020

Having the same issue here, The problem seems to be related to contextIsolation: true, if you set it to false it works but you can't use contextBridge on your preload.js since contextBridge require contextIsolation to be true.

If you log the value of app.electron with contextIsolation: true, it is undefined but with contextIsolation: false, it contains an object.

I try adding this line to preload. js without luck
contextBridge.exposeInMainWorld('electronRequire', require);

@shadow-light
Copy link

shadow-light commented Aug 29, 2021

Looks like Spectron needs significant changes to fix this: #896 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants