The code below is not working. It fails on nightmare.screenshot('./screenshots/error_inner.png') in the catch clauses. The error messages suggests it's actualy trying to read rather than write the file: error_inner.png
Is there anyone who knows how to get the screenshot when the error occurs. Help is much appricated /Tomas Hesse
var Nightmare = require('nightmare'),
nightmare = Nightmare({
show: true,
height: 1080,
width: 1920
});
var myVar = 'Non init';
nightmare
.goto('http://localhost:8082/myPage1')
.wait('.recloc')
.screenshot('./screenshots/tada.png')
.evaluate(() => { return document.querySelector('span.myClass').innerHTML;})
// .end()
.then((textFound) => {
myVar = textFound;
console.log('Outer nightmare Sucess:', textFound);
nightmare.goto('http://localhost:8082/myPage2')
.wait('#nav > ul.pull-left.navigation.hidden-xs > li:nth-child(3) > a')
.click('Non existing Element ie Error is thrown')
.end()
.then(()=>{
console.log('Outer nightmare Sucess:', myVar )
})
.catch((error) => {
nightmare.screenshot('./screenshots/error_inner.png')
console.error('Inner nightmare failed:', error);
return nightmare.end();
})
})
.catch((error) => {
console.error('Outer nightmare failed:', error);
nightmare.screenshot('./screenshots/error_outer.png')
return nightmare.end();
});