This is a migrated thread and some comments may be shown as answers.

Displaying captured browser image

1 Answer 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 27 Apr 2011, 03:29 PM
Hey all,

I'm using TFS in conjunction with the free version of WebAii and .NET 4 to automate my WebAii tests, and I've run into a problem where when the test fails, I have no real way of seeing why the test fails, other then some debugging code I write.  I want to be able to display the image of the failed browser screen somewhere.  Ideally, I'd love to be able to add it to the debug trace, or some other type of output, but I don't think that's possible.  Can anyone suggest a way for me to be able to display the image I capture after a failed test, so when I look at the test result I immediately know why it failed?

Or even suggest some best practices in debugging why the test fails via some sort of output displayed in the test result.  I just want it completely simplified, so when ANYONE looks at the test results, they immediately know why it failed.

Thanks

1 Answer, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 28 Apr 2011, 03:17 PM
Hi Peter,
    you can capture an image of the browser at any point in the test and save that image to the hard drive. Here's how it looks in code:
System.Drawing.Bitmap image = ActiveBrowser.Capture();
image.Save("C:\\MySavedImages\\CurrentBrowser.png", System.Drawing.Imaging.ImageFormat.Png);
The best place for this piece of code is probably inside a catch(Exception e) {} block. That way you'll have an image of the browser at the time of failure - that can be extremely useful.

Obviously, there are plenty of other things you can do with the captured image other than simply saving it to the hard drive.

I hope this helps, please let me know whether you have any additional questions on this.

Kind regards,
Stoich
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Peter
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Share this question
or