var addLinkMatch = function () {
return function(Nightmare) {
console.log("some")
Nightmare.action('addLinkMatch', (name, options, parent, win, renderer, done) => {
console.log("extension start adding")
parent.respondTo('addLinkMatch', (done) => {
console.log("extension will be added")
win.addDevToolsExtension('..//dist').addLinkMatch(done);
console.log("extension was added")
});
done();
},
function (done) {
this.child.call('addLinkMatch', done);
});
}
}
document.getElementById("start").addEventListener("click", function(){
document.getElementById("status").innerHTML = "Searching for the gem";
nightmare
.goto('http://yahoo.com')
.type('form[action*="/search"] [name=p]', 'github')
.click('form[action*="/search"] [type=submit]')
.wait('#main')
.use(addLinkMatch())
.evaluate(function () {
win.addDevToolsExtension()
})
.evaluate(function () {
console.log(document.querySelector('#main .searchCenterMiddle li a').href)
return document.querySelector('#main .searchCenterMiddle li a').href
})
.then(function (result) {
document.getElementById("results").innerHTML = result;
})
.catch(function (error) {
document.getElementById("results"). innerHtml = "Search failed: " + error;
});
})
document.getElementById("stop").addEventListener("click", function(){
nightmare
.end()
.then(function (result) {
document.getElementById("status").innerHTML = "Leaving Nightmare Speechless";
})
}) `
Hi gitter, I really love nightmare and am utilizing it inside containers for PDF generation, automated testing and consumer based testing. I do have one thing that is a little unclear in the docs to me.
Supposedly we can set up a listener for console events like this:
.on('console', function(type [, arguments, ...]))
These events are not firing for me, is there a reliable way you all are using to capture console events, most importantly if a console.error
is thrown?
Thanks!