Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Right now as per default setting I am able to get screen shot for failed status but not for pass, per as per the requirement I need to attach for pass as well.

Any one please suggest any framework or function for that .

share|improve this question
4  
You need to word your question more carefully to get targeted answers. I presume you're testing a software GUI. What tool(s) are you using for testing? Are you testing a web front-end or an application front-end? You mention a "default setting" but not the program in which the setting exists. At the moment the answers to your question are infinite, and most of them won't be helpful to you. Hope that helps! –  kinofrost Sep 20 '11 at 11:48
2  
If you have a screen shot for failure how did you get it? Can't you use the same tool for a pass as well as a for a failure? –  MichaelF Sep 20 '11 at 13:03
    
Based upon my experience and the limited detail in the question, I answered using TestComplete as the tool. However, a targeted answer will not happen until the tool is specified. –  TristaanOgre Sep 21 '11 at 20:24

5 Answers 5

Selenium should work. Not sure if Watir/Watin supports this. If Selenium doesn't cut it for you, I've incorperated SnagIt into previous automation suites for screenshots at specific times. The only downside to the SnagIt route is that it would need to be installed on whatever machine happens to be running the tests.

share|improve this answer

"Right now as per default setting I am able to get screen shot for failed status but not for pass"

What test automation tool are you using? Most tools have the capability of taking a screenshot at any time.

I use WinTask. It has a HardCopy() function that is simple to use for these types of situations.

share|improve this answer

This, honestly, sounds like default behavior for TestComplete by SmartBear. There's a setting that, when log entry categorized as "Error" is made (either automatically by the engine or by a deliberate "Log.Error()" call), it will capture the current desktop as an image in the log file (image below is from the project properties in the Playback option).

Post image on error option

If the tool is TestComplete, then, all you need to do is explicitly call the "Log.Picture()" method on a successful run of a test. Insert that in your code and you have a screenshot.

If you're using keyword tests, you would need to use the "Post Screenshot" operation

Post Screenshot operation

This will put the screenshot into your log as well in the same fashion that Log.Picture does.

If your tool is not TestComplete, then I'm pretty sure there are similar functions/methods/features in other testing packages that can do the same thing.

share|improve this answer

I assume that you are talking about using CodedUI tests that are part of Microsoft Test Manager, which only take a screenshot on failed tests. You can write some code to capture the image and call as part of your cleanup before you close the browser. Watin has code to do this which you can see here.

share|improve this answer

//Add screenshot code as your final test step

ScreenCapture sc = new ScreenCapture(); // capture entire screen, and save it to a file Image img = sc.CaptureScreen(); // display image in a Picture control named imageDisplay this.imageDisplay.Image = img; // capture this window, and save it sc.CaptureWindowToFile(this.Handle,"C:\temp2.gif",ImageFormat.Gif);

//Or for capturing the current window use

Rectangle bounds = this.Bounds; using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(new Point(bounds.Left,bounds.Top), Point.Empty, bounds.Size); } bitmap.Save("C://test.jpg", ImageFormat.Jpeg); }

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.