The best way to inspect HTTP response headers with Selenium

globulus picture globulus · Mar 24, 2009 · Viewed 34.7k times · Source

I need the best way to inspect HTTP response headers with Selenium. I looked around the Selenium docs and didn't see any straightforward way to do it. Help is highly appreciated.

Answer

 picture · Jul 24, 2009

captureNetworkTraffic() API in DefaultSelenium captures http request/response headers and you can access them in html/xml/plain format.

Here is sample code:

Selenium s = new DefaultSelenium(...);
s.start("captureNetworkTraffic=true");
s.open("http://www.google.com");
String xml = s.captureNetworkTraffic("xml"); // html, plain
s.stop();