views:

474

answers:

4

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 or packet sniffer 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.

Can I easily get the HTTP-specific information from WinpCap?

A: 

Have you looked at implementing an Http Module or an Http Handler (.ashx)? They will allow you to intercept each and every web request and process them as you need before getting to your page.

SaaS Developer
These are requests for 3rd party sites
Mark Cidade
So your automated tests are going to depend on live third-party sites then?
Chris
+1  A: 

Try winpcap . It's a driver/library combination which can be used to monitor packets. Based on what you are trying to do (watch traffic w/o a UI), this is probably a simpler solution than writing your own proxy.

Brian
+1  A: 

There are numerous apps for this. My recommendation is Wireshark

Geoff
+1  A: 

You probably don't want to proxy, that will introduce a lot of unnecessary complexity.

Consider packet sniffing instead, which is pretty much a solved problem. Wireshark is handy as a stand alone utility you can use manually, but it's also possible to do packet sniffing programmatically, using WinPcap, the library on which Wireshark is based. Here's a couple of examples of WinPcap in .Net, .NetNomad's example with sample project, and a CodeProject tutorial, also with source.

Factor Mystic