Intern / Leadfoot: How to get HTTP status codeAsk Question


How can I determine the HTTP status after moving to some page using intern?

this.remote.get('') // status 200
this.remote.get('') // 404 Not Found


So here's the hack..Use BrowserMob proxy and send your requests via BrowserMob Proxy and these proxy will give you all the relevant status codes you wish to have.
Here is a sample of code that uses browsermob proxy to save last response code to a variable:

    int lastResponseCode;

    ProxyServer server = new ProxyServer(8888);

    server.addResponseInterceptor(new HttpResponseInterceptor() {
      public void process(HttpResponse response, HttpContext context) throws HttpException,
IOException {
        lastResponseCode = response.getStatusLine().getStatusCode();

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability(CapabilityType.PROXY, server.seleniumProxy());
    WebDriver driver = new FirefoxDriver(caps);

And the reason why status codes will never be supported in selenium Webdriver is here:

标签: intern leadfoot
© 2014 TuiCode, Inc.