Selenium 1 has a built-in mechanism to record network traffic and http requests by setting the selenium.start(“captureNetworkTraffic=true”);
Unfortunately this solution is not available “out of the box” in Selenium 2 or WebDriver.
You can capture network traffic using a proxy, such as the BrowserMob Proxy (http://proxy.browsermob.com)
To configure the use of the proxy with a webdriver instance, set the CapabilityName.PROXY value to a org.openqa.selenium.Proxy instance:
Proxy proxy = new Proxy();
// The URL here is the URL that the browsermob proxy is using
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
WebDriver driver = new FirefoxDriver(capabilities);
Once the test is finished, you can extract the data from the browsermob proxy using the mechanisms it provides.
Note: “new Proxy()” – Needs org.openqa.selenium.Proxy.