capturing Screenshots for the failure tests using QTP- Urgent

2,576 views
Skip to first unread message

Mathi_QA Engineer

unread,
Sep 17, 2008, 3:20:30 AM9/17/08
to QTP - HP Quick Test Professional - Automated Software Testing
Hi,
Anyone please help me how to take the screen shot of the failure test
cases and add them in the test results for the Jaav application.. It
would be helpful If you help with the script..

Thanks in Advance

Vivek Prakash

unread,
Sep 19, 2008, 1:29:41 AM9/19/08
to Mercu...@googlegroups.com
use statement - Setting("SnapshotReportMode") = 0 at the beginning of the script.

Codes for SnapshotReportMode are as follows:

 
0 - always captures images.
1 - captures images only if an error occurs on the page.
2 - captures images if an error or warning occurs on the page.
3 - never captures images.
Default = 1.

when you use snapshotReportMode property, it will capture the object on which any action is performed(depending on the value you use for this property, if you use 0, it will capture all screen shots, however, if you use, 1, it will capture screen shots for only those objects which results in an error).

In Test result, just click on the object of which you want to see the screen shot.  It will be displayed there.

Note:  This property will not capture objects on which you have just used Exist method only and have not performed any action like click or set ...

Regards,
Vivek

Mathi_QA Engineer

unread,
Sep 19, 2008, 3:40:48 AM9/19/08
to QTP - HP Quick Test Professional - Automated Software Testing
Hi Vivek,
Thanks for your response.
i tried this and it is working. i have another one doubt,
As of now i am reporting all of my defects in excel file. When
using the SnapshotReportMode method, QTP reports the images in QTP
results. Can i get those snapshots in my own location or in the excel
file which i am creating?

Thanks in advance,
mathi

On Sep 19, 10:29 am, "Vivek Prakash" <vivekpa...@gmail.com> wrote:
> use statement - Setting("SnapshotReportMode") = 0 at the beginning of the
> script.
>
> Codes for SnapshotReportMode are as follows:
>
> *0* - always captures images.
> *1* - captures images only if an error occurs on the page.
> *2* - captures images if an error or warning occurs on the page.
> *3* - never captures images.
> *Default = 1*.
>
> when you use snapshotReportMode property, it will capture the object on
> which any action is performed(depending on the value you use for this
> property, if you use 0, it will capture all screen shots, however, if you
> use, 1, it will capture screen shots for only those objects which results in
> an error).
>
> In Test result, just click on the object of which you want to see the screen
> shot.  It will be displayed there.
>
> *Note:  This property will not capture objects on which you have just used
> Exist method only and have not performed any action like click or set ...*
>
> Regards,
> Vivek
>
> On Wed, Sep 17, 2008 at 12:50 PM, Mathi_QA Engineer
> <mathipra...@gmail.com>wrote:
>
>
>
>
>
> > Hi,
> > Anyone please help me how to take the screen shot of the failure test
> > cases and add them in the test results for the Jaav application.. It
> > would be helpful If you help with the script..
>
> > Thanks in Advance- Hide quoted text -
>
> - Show quoted text -

Vivek Prakash

unread,
Sep 19, 2008, 1:12:46 PM9/19/08
to Mercu...@googlegroups.com
Hi Mathi,

you can use CaptureBitmap method if you need to store the snapshots in different location.
However, you may need to do a bit of additional coding to get the snapshot for all errors (try using "if" condition with "exist" and in "else" statement use captureBitmap method)

Syntax: (you can get it in qtp help file also)

object.CaptureBitmap FullFileName, [OverrideExisting]

Browser(B).Page(P).WebEdit(x).CaptureBitmap "d:\my_folder\EditSnap.bmp", True

Regards,
Vivek

KANDUKURI NARESH

unread,
Sep 19, 2008, 10:15:10 AM9/19/08
to Mercu...@googlegroups.com
Hi,
According to my knowledge,
even you can use the "CaptureBitmap" option for each and every hierarchy... where you feel that Error will come...
For Ex:
 
Browser("gmail").CaprureBitMap "path\knk.bmp", 1
 
It is better to save in the ".bmp" format...

Dhanasekar Subramaniam

unread,
Sep 19, 2008, 7:26:57 PM9/19/08
to Mercu...@googlegroups.com
hi
     you can use capture error option under one of the QTP settings,it comes under options r settings.
 
Thanks
Dhanasekar S
2008/9/19 KANDUKURI NARESH <kandu...@gmail.com>



--
Regards,
Dhanasekar S.
http://testingideas.wordpress.com
---------------------------------------------------------
Let us make the World Greener
http://www.greenpeace.org/international/
-----------------------------------------------------------

sarath

unread,
Sep 22, 2008, 12:32:17 PM9/22/08
to QTP - HP Quick Test Professional - Automated Software Testing

try the below function this may help you, jus give the path of the
location you want save the screen shot

Public Function DesktopCapture
On Error Resume Next
Dim filename, Lfilename,datestamp
datestamp = Day(date) &"-"& Month(date) &"-"& Year(Date) &"_"&
Hour(Now) &"."& Minute(Now) &"."& Second(Now)
filename = datestamp & ".png"
Lfilename = Path you want save the snapshot & "\" & filename
Desktop.CaptureBitmap Lfilename, true
Reporter.ReportEvent micWarning,"","&lt;<img src='" & Lfilename &
"'>"
End Function

On Sep 20, 4:26 am, "Dhanasekar Subramaniam" <dhanasek...@gmail.com>
wrote:
> hi
>      you can use capture error option under one of the QTP settings,it comes
> under options r settings.
>
> Thanks
> Dhanasekar Shttp://testingideas.wordpress.com
>
> 2008/9/19 KANDUKURI NARESH <kanduku...@gmail.com>
>
>
>
> >  Hi,
> > According to my knowledge,
> > even you can use the "CaptureBitmap" option for each and every hierarchy...
> > where you feel that Error will come...
> > For Ex:
>
> > Browser("gmail").CaprureBitMap "path\knk.bmp", 1
>
> > It is better to save in the ".bmp" format...
>
> > On Wed, Sep 17, 2008 at 12:50 PM, Mathi_QA Engineer <mathipra...@gmail.com
> > > wrote:
>
> >> Hi,
> >> Anyone please help me how to take the screen shot of the failure test
> >> cases and add them in the test results for the Jaav application.. It
> >> would be helpful If you help with the script..
>
> >> Thanks in Advance
>
> --
> Regards,
> Dhanasekar S.http://testingideas.wordpress.com

b sridhar

unread,
Oct 4, 2008, 1:58:14 AM10/4/08
to Mercu...@googlegroups.com
Hi,
 
    There is option to capture failures of screen shot in between execution of the script.Go to Run tab and there is a option to set as per your requirement like capturing screen shots at the error time only or at the time of warnigs or always.I think it will resolve your problem.
 
Keep posting any query
Sridhar

 
Reply all
Reply to author
Forward
0 new messages