Capturing page resources (css, js, images) using Selenium 2 in IE
I'm using Selenium 2 (in IE only) and I need to capture all page resources (js, css, images files etc.) and their HTTP status. I tried to use HTTP analyzer for thi开发者_开发百科s but this tool is very unstable and crashes all the time. Could you please advise how I can resolve my problem?
You will need to use a proxy to do something like this. Selenium does not intercept HTTP traffic so cannot do this itself (There is an old capturenetworktraffic implementation in Selenium 1 but that was using some FireFox specific code and did not work for any other browsers).
To configure it:
Proxy proxy = new Proxy();
proxy.setHttpProxy(<proxyAddress>);
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(cap);
This should enable you to capture network traffic and as a result capture http status codes of various page resources.
精彩评论