views:

239

answers:

1

I'm using browser automation for testing web sites but I need to verify HTTP requests from the browser (i.e., images, external scripts, XmlHttpRequest objects). Is there a way to programmatically instantiate a proxy for the browser to use in order to see what its sending?

I'm already using Fiddler to watch the traffic but I want something that's UI-less that I can use in continuous build integration.

+3  A: 

I have briefly looked into the same thing and have considered two solutions (but haven't tried them yet).

The first suggestion I have would be to use the HttpListener class (and possibly Webclient or other System.Net http related classes to re-post the requests to your application) as a proxy for the WebBrowser test calls. I have no experience with HttpListener, but it looks like a simple and promising way to proxy calls through to your app.

The second suggestion I have is to do what Fiddler does: tap into the WinINET Http stack on your test machine to act as a proxy (with some sort of filter to narrow it down to JUST your WebBrowser's calls). Unforunately, the best example of this I have been able to find is Fiddler itself and the only way I know to get the code is Reflector. It might be possible to get to the Fiddler proxy code another way, but I did not have time to investigate this path fully.

HTH!, Richard

ZeroBugBounce
I might just go ahead and reflect over Fiddler. Thanks.
Mark Cidade