Reputation: 38180
I downloaded PhantomJS, launched the exe and typed in console
var page = require('webpage').create();
page.open('http://net.tutsplus.com', function(s){console.log(s);})
I didn't see status "success" returned in console and no error either. Why?
I tried using hello.js it prints "success" but it does not in interactive mode, is this normal?
Upvotes: 1
Views: 158
Reputation: 61892
Don't use interactive mode to open pages. Something prevents PhantomJS from opening pages, so the callback is never called. If you wait a little and try to access page.content
it still shows the about:blank content. This is because REPL mode is broken.
Previous answer in case this is used as a script and not in interactive mode:
I believe this is a flush problem. Add a second console.log()
to see if the first one appears.
Also, it is always a good idea to close the script at which point the output will be flushed:
page.open('http://net.tutsplus.com', function(s){
console.log(s);
phantom.exit();
});
I could reproduce this issue on Raspbian with PhantomJS 2.0.1-dev once. All other invocations had no problem anymore.
Upvotes: 1