Expose the page response headers to Navigator object to make them available from Selenium and other web driversThis is a technical extension to be used with web drivers like Selenium. It adds the so-needed functionality like providing response headers and response status code for requested urls. The available items go to Navigator object, under following properties:
To get those values, you typically need to get them by running a javascript in a page context, and returning the result. In Selenium, it would look something like this:
var builder = new selenium.Builder().withCapabilities(selenium.Capabilities.chrome());
var options = new selenium_chrome.Options();
options.addExtensions(__dirname + "/response-headers.crx");
builder.setChromeOptions(options);
var page = builder.build();
page.then(function() {
// load your url here
}, function(err) {
// error creating browser
});
/// then somewhere after loading the url, you would do
page.executeScript(function() {
return {
statusCode: navigator.responseStatusCode
}
}).then(function(obj) {
// now you have obj.statusCode
});