Recently, my scripts in PhantomJS browser have stopped running. Whenever I try to capture screens, all I get are black screens. To troubleshoot this, I manually opened a URL in PhantomJS using the command window and ran the script below to verify if it opens successfully:
var page = require('webpage').create(),
system = require('system'),
t, address;
if (system.args.length === 1) {
console.log('Usage: loadspeed.js <some URL>');
phantom.exit();
}
t = Date.now();
address = system.args[1];
page.open(address, function(status) {
if (status !== 'success') {
console.log('FAIL to load the address');
} else {
t = Date.now() - t;
console.log('Loading ' + system.args[1]);
console.log('Loading time ' + t + ' msec || Loading time ' + (t/1000) + '
sec ' );
}
phantom.exit();
});
========================================================================= 1. Running the command in phantomjs window provides the loading time of any given URL https://i.stack.imgur.com/BwjkA.jpg
- In my specific application case, this method fails https://i.stack.imgur.com/1LM7r.jpg
Note: Interestingly, this issue does not occur when using other browsers such as Chrome or Firefox.
I am puzzled by this sudden failure on PhantomJS. Can anyone provide some insights or reasons behind this? Any help will be greatly appreciated.
- Please find attached a screenshot captured from the Firefox network console which demonstrates that the http GET request is allowed for the URL. https://i.stack.imgur.com/I0Sfx.jpg