Chrome Extension: https://chrome.google.com/webstore/detail/expose-response-headers/omlflgllokdkamhdgiaalffaeopelagg
Last active
March 2, 2017 10:37
-
-
Save javascriptlove/4a00c4931c4c83287f4efd6c23fd02ed to your computer and use it in GitHub Desktop.
Getting http response code with Selenium and Expose Response Headers extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// uses Expose Response Headers extension for Chrome | |
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() { | |
page.get(url).then(function() { | |
page.executeScript(function() { | |
return { | |
statusCode: navigator.responseStatusCode | |
} | |
}).then(function(obj) { | |
// now you have obj.statusCode | |
}); | |
}, function(err) { | |
// error opening url | |
}); | |
}, function(err) { | |
// error creating browser | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment