PNG wird nicht mit PhantomJS mit mehreren Versuchen in einer Schleife gerendert.

var page = require('webpage').create();
var filepath = "/home/abc/" + "abc.html"; //create path to charts.html    
for (i = 0; i < 3; i++) { // make three attempts
    console.log("hi")
    page.open(filepath, function(status) {
      console.log(status);
      //if(status !== 'success') { //if not success, make another attempt
//        continue;
  //    }

      page.render('abc.png');
      phantom.exit();
    });
}    
phantom.exit();

diesen Code wie folgt ausführen:

$ phantomjs hello.js

Q1: Ich erwarteabc.png in meinem Heimatverzeichnis erzeugt werden. Mit dem aktuellen Code wird es jedoch nicht generiert.

Q2: Das Hinzufügen des auskommentierten Blocks führt dazu, dass die Codeausführung hängen bleibt. Warum so?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage