I installed nightmare with npm install nightmare --save in my meteor project. I then tried to run the nightmare sample code within a template helper method:
Template.nighmare.events({ "click #doSomething"() {
let Nightmare = require('nightmare');
let nightmare = Nightmare({ show: true });
nightmare
.goto('https://duckduckgo.com')
.type('#search_form_input_homepage', 'github nightmare')
.click('#search_button_homepage')
.wait('#zero_click_wrapper .c-info__title a')
.evaluate(function () {
return document.querySelector('#zero_click_wrapper .c-info__title a').href;
})
.end()
.then(function (result) {
console.log(result);
})
.catch(function (error) {
console.error('Search failed:', error);
});
} })
which is triggered by the code Do something
I then get the exception: Uncaught TypeError: fs.existsSync is not a function at meteorInstall.node_modules.electron.index.js (modules.js?hash=1ae810a…:109967) at fileEvaluate (modules-runtime.js?hash=0969a31…:207) at require (modules-runtime.js?hash=0969a31…:130) at meteorInstall.node_modules.nightmare.lib.nightmare.js (modules.js?hash=1ae810a…:107767) at fileEvaluate (modules-runtime.js?hash=0969a31…:207) at require (modules-runtime.js?hash=0969a31…:130) at Object.click #doSomething (app.js:4330) at blaze.js?hash=813922c…:3774 at Function.Template._withTemplateInstanceFunc (blaze.js?hash=813922c…:3743) at Blaze.View. (blaze.js?hash=813922c…:3773)
I have no Idea how to fix this, any tip or hint would be appreciated! Anyone that got meteor + nightmare to work together?
If I put the same code in a test.js file and run it with node test.js in its own project works just fine.
via Hans Brattberg
No comments:
Post a Comment