I am trying to run nightmare in a while loop. My problem is that the while loop is not waiting for nightmare to finish. That's my example code:
var Nightmare = require('nightmare');
var Screenshot = require('nightmare-screenshot');
var i = 0;
while(i < 10) {
var nightmare = new Nightmare();
nightmare.goto('https:/website/?id='+ i);
nightmare.screenshot('/home/linaro/cointellect_bot/screenshot1.png');
nightmare.use(Screenshot.screenshotSelector('screenshot' + i + '.png', 'img[id="test"]'));
nightmare.run();
}
Is it possible to let the loop wait until nightmare has finished it's function queue? What other options do I have?