Giter Site home page Giter Site logo

Comments (12)

kevinsawicki avatar kevinsawicki commented on July 24, 2024 1

Also, does your app have nodeIntegration enabled in both windows?

from spectron.

kevinsawicki avatar kevinsawicki commented on July 24, 2024

BTW windowHandles is missing in the readme.

The app.client API is currently documented at http://webdriver.io/api.html

from spectron.

kevinsawicki avatar kevinsawicki commented on July 24, 2024

console.log(await app.client.browserWindow.getTitle());

This should be this instead:

console.log(await app.browserWindow.getTitle());

from spectron.

kevinsawicki avatar kevinsawicki commented on July 24, 2024

unknown error: window[requireName] is not a function

Do you have more of the stack trace that raised this error?

from spectron.

kevinsawicki avatar kevinsawicki commented on July 24, 2024

Also, does app.client.getTitle() work for you?

from spectron.

wojtkowiak avatar wojtkowiak commented on July 24, 2024

Thank you very much for your time.
unknown error: window[requireName] is not a function unfortunately this did not appeared with a stack trace (I am using ava).

Thanks to your hints I made it work. The problem was nodeIntegration being disabled indeed. So it seems that this error was actually triggered by windowByIndex.

I changed app.client.browserWindow.getTitle() to app.browserWindow.getTitle() and it works. app.client.getTitle() works also.

So after all maybe adding a note in readme about nodeIntegration would be helpful.

I have one more question if I may - can I talk to the main process ipc directly from tests? I am trying to trigger some things directly from the tests instead of the renderer process.
I have tried const ipc = app.electron.ipcRenderer; but ipc.send does not seem to send to the main process. Is there any way to do that or do I just have to setup another ipc connection myself?

from spectron.

kevinsawicki avatar kevinsawicki commented on July 24, 2024

So after all maybe adding a note in readme about nodeIntegration would be helpful.

Good point, I added https://github.com/electron/spectron#node-integration today which hopefully makes thing clearer.

can I talk to the main process ipc directly from tests?

It should work, I just uploaded a simple spec to test it and it appears to pass currently, 6d36884

from spectron.

wojtkowiak avatar wojtkowiak commented on July 24, 2024

Hmm app.electron.ipcRenderer.send('ipc-event', 'test') does not work for me. Not sure what is the reason.

from spectron.

wojtkowiak avatar wojtkowiak commented on July 24, 2024

Oh wait, got it. Seems that when you use ipcRenderer also in html that is loaded in your app it takes precedence and using it directly in tests fails then. So it seems that it will only work if you somehow disable ipc in the renderer for test purposes.

from spectron.

kevinsawicki avatar kevinsawicki commented on July 24, 2024

Seems that when you use ipcRenderer also in html that is loaded in your app it takes precedence and using it directly in tests fails then. So it seems that it will only work if you somehow disable ipc in the renderer for test purposes.

Hmm, that is surprising, could you include the code to help me reproduce this locally?

from spectron.

wojtkowiak avatar wojtkowiak commented on July 24, 2024

Good that you have asked.
I've forked spectron and changed the fixtures/app just to find out that it works. Now I've reverted my changes from yesterday and it also works 😄
So it seems that I had some other problem somewhere which I probably fixed with other changes. It started working when I removed var ipc = require('electron').ipcRenderer; from my index.html but it seems that this was only coincidence.
Tried to nail it but my IDE did not keep so detailed track of local changes.
So anyway, thank you for your time once again!

from spectron.

Stoyko83 avatar Stoyko83 commented on July 24, 2024

[quote]Also, does your app have nodeIntegration enabled in both windows?[/quote]

How can I check about that? Where is this setting defined?

from spectron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.