I have a web application which is built with AngularJS. I am using phantomjs network monitoring for sniffing all requests triggered from the website on a page load. I get the following list of requests:
"https:.../assets/application-bf61473a35661d960c262995b314b0af.css"
"https:.../assets/lib/modernizr-c569e351684c78953f5f6298b4e1e485.js"
"https:.../assets/application-04936fc61dbebda777c3f816afa39726.js"
"https://www.google-analytics.com/analytics.js"
"https://ssl.google-analytics.com/ga.js"
"https:.../assets/app_install_page_header-a4b182016c1769bad626d1409b6c95f1.png"
"https:.../assets/app_install_page_landing_text-14a162dca43a9a84b9fe0a7a77472fad.png"
The problem is that the list doesn't include any dynamic requests such as:
request with data for google analytics;
request for pictures witch are requested from a backend;
- ...
I used a waitFor method in order to give phantomjs time to wait for the delayed requests but it didn't help.
I used this documentation http://phantomjs.org/network-monitoring.html.
Code:
var page = require('webpage').create();
page.onConsoleMessage = function(msg, lineNum, sourceId) {
console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")');
};
page.onError = function(msg, trace) {
var msgStack = ['ERROR: ' + msg + trace];
console.error(msgStack.join('\n'));
};
page.onResourceRequested = function(request) {
url = request.url
console.log(url);
};
page.onRecourseReceived = function(response) {
console.log('received: ' + JSON.stringify(response, undefined, 4));
};
page.onLoadFinished = function() {
page.render("on_finish.png");
};
page.open(address, function(status){
setTimeout(function(){
phantom.exit();
}, 15000);
});