views:

115

answers:

2

I am writing a WinForms app which will execute some web UI tests written in a web testing framework.

Is there a way I can get the error on the page being tested (I specify the page through a method parameter) without screenscraping the page? For example, if it throws:

A potentially dangerous Request.QueryString value was detected from the client

How can I detect this?

EDIT:

One way would be to scrape just the title.

+3  A: 

I would actually suggest you look into something called ELMAH. If you put ELMAH on your ASP.NET website it will automatically log and handle all the exceptions that get thrown by your app as you are testing it. You can have it store all the entires as XML files or in a database. You can also have it email you directly with a copy of the Yellow Screen of Death (including stack trace).

This would be a lot easier for you then trying to program the same functionality into your winforms app. Just use your app to beat the ASP.NET site up and let ELMAH handle the error logging.

TheTXI
Ah yes, ELMAH. Great app, and I love the ability to put exceptions into an RSS feed etc. I'm not too keen on this as it will mean I have to modify the app being tested, which is large and I haven't got much experience on. So far, the only other approach is to scrape. Thanks for the idea and I'll weigh up my options (not just technical points) :)
dotnetdev
Does it really require that much work to plug in? All you should have to do is add in a new .dll and add a little to the web.config? I honestly believe that it would take far-less time setting that up than it would be trying to implement a screen scraping feature on your tester. Just my $0.02 :)
TheTXI
Yeah you're right. I guess you can't have everything :)
dotnetdev
+1  A: 

What about trapping the error at the Application level (with a global handler in .asax) and sending the exceptions data to a db? Which you can then query.
Hmm, or even, implementing a WCF dual binding, that you call the clients listening on, when an error occurs. Your windows form can be a proxy waiting for notifications. But maybe, that might not be a good idea, as you would want to have your test, separate from your application. What about using something like Enterprise library to log to an MSMQ, which you can be listening on via the windows form?

EDIT - the ELMAH suggestion above looks good as well

Irwin
I was actually wondering how to fulfill my requirement without editing the existing app but I guess that has to be done now. If so, all of these ideas are great and I thought of them too (health monitoring, Ent Lib which I use at home, etc).
dotnetdev