I'm trying to access some QUnit test urls using phantomjs (version 1.9.1, on Windows). I'm behind a proxy at a corporate site but the URLs I'm trying to access are being served from my local development workstation, plus I've even tried accessing the same URLs with two other browsers (Hv3 and Dooble) without the necessary proxy settings, and they get an HTML response, even if they can't execute the QUnit javascript.
So I've even tried adjusting the javascriptEnabled setting (plus another couple of settings, see code below) to false to try to just get the raw HTML, but to no avail. I've wrapped my call to page.open in a try/catch but apparently this is not because of an exception; rather a console.log statement immediately before the final phantom.exit() statement gets executed.
Furthermore I've followed recommendations from https://github.com/ariya/phantomjs/wiki/Network-Monitoring including logging from page.onResourceRequested, page.onError and page.onResourceReceived, and only the callback for onResourceReceived gets executed. And I'm specifying the --proxy-type=none command line argument, all to no avail.
Code and output below, thanks in advance. I'm at a loss; maybe it's a phantomjs issue? Just want to rule out everything before reporting it though.
CODE:
var page = require('webpage').create();
page.onResourceRequested = function (request) {
console.log('Request ' + JSON.stringify(request, undefined, 4));
};
page.onResourceReceived = function (response) {
console.log('Receive ' + JSON.stringify(response, undefined, 4));
};
page.onError = function (msg, trace) {
console.log(msg);
trace.forEach(function(item) {
console.log(' ', item.file, ':', item.line);
})
}
page.settings.webSecurityEnabled = false;
page.settings.localToRemoteUrlAccessEnabled = true;
//page.settings.javascriptEnabled = false;
for (var setting in page.settings) {
console.log(setting + ": " + page.settings[setting]);
}
try {
page.open('http://local.example.com:9001/test/workflow', function() {
console.log('page opened');
});
}
catch(xcep) {
console.log(xcep);
}
console.log('before exit');
phantom.exit();
OUTPUT:
XSSAuditingEnabled: false
javascriptCanCloseWindows: true
javascriptCanOpenWindows: true
javascriptEnabled: true
loadImages: true
localToRemoteUrlAccessEnabled: true
userAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34
webSecurityEnabled: false
Request {
"headers": [
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.1 Safari/534.34"
},
{
"name": "Accept",
"value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
],
"id": 1,
"method": "GET",
"time": "2013-07-12T09:49:58.262Z",
"url": "http://local.example.com:9001/test/workflow"
}
before exit