Closed mohitps7 closed 4 years ago
You need to do something with dream for it to pop up Try running the example: https://github.com/YZYLAB/dream-js/blob/master/example.js
Thanks for your response. I am able to clone the repository and run node example.js
and it works fine as expected.
However after installing the module and running the example code within my electron app on startup:
const Dream = require('@yzylab/dream-js')
const dream = new Dream({
show: true,
openDevTools: { detach: true }
})
dream
.useragent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36')
.goto('https://bot.sannysoft.com/')
.evaluate(function(){
return document.body.innerHTML;
})
.wait(10000)
.end()
.then(function(result) {
console.log(result)
})
Gives this error:
(node:44712) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object at validateString (internal/validators.js:112:11) at normalizeSpawnArguments (child_process.js:411:3) at Proxy.spawn (child_process.js:547:16) at Dream.<anonymous> (pathto\node_modules\@yzylab\dream-js\lib\dream.js:126:24) at next (pathto\node_modules\@yzylab\dream-js\lib\dream.js:333:14) at Dream.run (pathto\node_modules\@yzylab\dream-js\lib\dream.js:323:5) at pathto\node_modules\@yzylab\dream-js\lib\dream.js:484:12 at new Promise (<anonymous>) at Dream.then (pathto\Turbo AIO\node_modules\@yzylab\dream-js\lib\dream.js:482:12) at App.<anonymous> (pathto\main.js:56:8)
And running this gives no errors, but nothing is logged and the window isn't opened:
const Dream = require('@yzylab/dream-js')
const dream = new Dream({
show: true,
openDevTools: { detach: true }
})
dream
.useragent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36')
.goto('https://bot.sannysoft.com/')
.evaluate(function(){
console.log(document.body.innerHTML);
})
.wait(10000)
.end();
Any ideas why?
Thanks for your response. I am able to clone the repository and run
node example.js
and it works fine as expected.However after installing the module and running the example code within my electron app on startup:
const Dream = require('@yzylab/dream-js') const dream = new Dream({ show: true, openDevTools: { detach: true } }) dream .useragent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36') .goto('https://bot.sannysoft.com/') .evaluate(function(){ return document.body.innerHTML; }) .wait(10000) .end() .then(function(result) { console.log(result) })
Gives this error:
(node:44712) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object at validateString (internal/validators.js:112:11) at normalizeSpawnArguments (child_process.js:411:3) at Proxy.spawn (child_process.js:547:16) at Dream.<anonymous> (pathto\node_modules\@yzylab\dream-js\lib\dream.js:126:24) at next (pathto\node_modules\@yzylab\dream-js\lib\dream.js:333:14) at Dream.run (pathto\node_modules\@yzylab\dream-js\lib\dream.js:323:5) at pathto\node_modules\@yzylab\dream-js\lib\dream.js:484:12 at new Promise (<anonymous>) at Dream.then (pathto\Turbo AIO\node_modules\@yzylab\dream-js\lib\dream.js:482:12) at App.<anonymous> (pathto\main.js:56:8)
And running this gives no errors, but nothing is logged and the window isn't opened:
const Dream = require('@yzylab/dream-js') const dream = new Dream({ show: true, openDevTools: { detach: true } }) dream .useragent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36') .goto('https://bot.sannysoft.com/') .evaluate(function(){ console.log(document.body.innerHTML); }) .wait(10000) .end();
Any ideas why?
Thank you for your response @urbanio, after looking through the NightmareJS errors I realised I needed to add this option when instantiating the Dream browser:
const dream = new Dream({
show: true,
electronPath: require('./node_modules/electron')
})
This issue has been fixed now, thank you!
Trying to run dream-js with electron. After requiring the module, running
const dream = new Dream({show: true})
doesn't load up a browser window nor does it show any errors.