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:
03 | Proxy proxy = new Proxy(); |
05 | proxy.setHttpProxy( "localhost:9100" ); |
07 | DesiredCapabilities capabilities = DesiredCapabilities.firefox(); |
08 | capabilities.setCapability(CapabilityType.PROXY, proxy); |
10 | 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.