I'm currently using Selenium Webdriver to do some validation on pages. The Webdriver is being driven by PhantomJS. I know that in PhantomJS, you can listen to the network using the example like the one below: (from https://github.com/ariya/phantomjs/wiki/Network-Monitoring).
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.open(url);
How can I achieve this functionality within the Webdriver? Can I bind a function to the DesiredCapabilities?