Closed jviotti closed 7 years ago
Actually, not even process
is defined. Looks like the app is running in a more restricted environment, and not in a normal Electron environment?
In this comment, the user seems to be running scripts using require()
with NightmareJS. I'll try various NightmareJS versions to see if it makes any difference.
Okay, I found the reason. nodeIntegration
is set to false
on runner.js
: https://github.com/segmentio/nightmare/blob/master/lib/runner.js#L71. Setting it to true
works like a charm. Any reason why this is disables? I'm happy to provide a PR to implement an option to control this value.
Any reason why this is disables?
Well, Nightmare is primarily meant to be a scripted web browser, and loading any content from the web into an environment where nodeIntegration = true
makes your whole machine extremely vulnerable to all manner of crazy attacks.
I’m not a committer or anything here, so I can’t say anything about whether other people might be interested in making this happen. Personally, though, I’m sure making that property changeable is really the best way to go about this. Using Nightmare (or something like it or its API) to control an Electron app is a really cool idea, but I think doing it right would require a much more thoughtful approach. Maybe better to fork it, make all the adjustments you wind up needing to make it work well for you, and come back with ideas about what actually worked out well (or not) in practice?
Closing as this as like @Mr0grog said, that isn't really what Nightmare is intended for. There may be a future where this is doable, but not for now.
Hi, we're trying to do something crazy here at https://github.com/resin-io/etcher. We're trying to automate the process of taking screenshots to our application (for the website, etc) by controlling the real Electron app with Nightmare.
The plan is to run the Etcher app with Nightmare utilities to drive the application into certain states, and take screenshots of it.
So far I tried the following:
electronPath
to the Electron Etcher binary generated when packaging the application. The app seems to run fine, but.evaluate()
blocks or any other Nightmare function don't seem to run at all.index.html
file of Etcher. This seems to work, and every NightmareJS function, including.evaluate()
works fine, however I get:require is not defined
. Any ideas? Is NightmareJS blockingrequire
calls from the site it opens?