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 .

  • 5
    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, 2011 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, 2011 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. Sep 21, 2011 at 20:24

5 Answers 5


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.


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.


"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.


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.

//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

//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);
  • You need to edit this answer to describe the framework and language you're using - it looks like Java or C#, but without context you've simply added a relatively low-information code snippet.
    – Kate Paulk
    Sep 30, 2015 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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