Almost every test object in QTP supports the method CaptureBitmap even the Desktop object.
During your test or within a recovery scenario you want to capture a screenshot of a specific object or the desktop. to later analyze the results.
Posted in Reports

daniva




April 17th, 2008 at 1:58 am
how to use as part od reportmanager???
April 18th, 2008 at 2:13 am
Can you more fully explain this please?
April 21st, 2008 at 10:55 am
This does not work when scripts are run from QC.
The image files cannot be linked if the different machine is used for viewing the logs other than the machine which ran the test.
April 30th, 2008 at 4:27 pm
I tried this with QTP 9.5 and always get a wrong URL in the report for the image :
URL : about:blank’C:\temp\Res1\test.png’
I dont know where this about;blank comes from
Could you please look into this?
May 14th, 2008 at 1:54 am
Image file is not displayed in test results window for QTP 9.5.
June 3rd, 2008 at 11:31 am
Hello,
Why is it displyaing image path starting from “about blank” and followed by the actual path.
That is causing problem for image to display in the report.
Anybody has any solution for this ? Please reply.
Thanks in advance.
June 3rd, 2008 at 11:56 pm
Hi to all
i have read the last comments
and you are right
something works wrong with QTP9.5 and this code.
i am trying to find a solution.
i will publish a solution for 9.5
June 4th, 2008 at 11:14 am
Hello Daniva,
I am working with 9.2 but still facing some issues. After lot of R&D, i found that there is some problem in the string which is assigned to the variable detailsStr.
I have done some changes and now its working fine for me. I guess, it should also work for other members as well. Please replace existing detailsStr variable value with following code –
detailsStr = “Captured Screen shot: “”lt;>”
Please let me know if its working for you.
June 7th, 2008 at 9:58 am
Dani,
I think this approach takes advantage of a security risk of embedding executable HTML code into an input field. I think QTP 9.5 has changed to convert the input data to a display-only non-executing format to mitigate this risk. Recently I sat in on an HP employee who was very adamant about improving security in upcoming releases.
June 9th, 2008 at 10:44 pm
after a reserch
i can tell that this code does not work in QTP9.5
QTP always put the “about:” prefix before the path.
in this way the link is lost inside the reporter.
sorry, i am working with this function almost 2 years…
i have to change it….
June 25th, 2008 at 11:47 am
I see the file is there in the Temp results directory, however getting a red X in the results.
June 26th, 2008 at 12:45 am
Refer to
http://www.advancedqtp.com/forums/index.php/topic,221.msg989.html#msg989
July 7th, 2008 at 7:53 am
I use QTP 9.5 integrated with QC 9.2. I use a similar kind of Function to embed Screenshots on the result file. But it is not displayed on the result file retrieved from QC. Is there any other round about way to do this?
July 23rd, 2008 at 5:20 am
This screenshot can’ be show up in Reporter in spite of using png or bmp image format.
July 26th, 2008 at 4:18 pm
[…] i posted a few months ago an embedded screenshot solution at the following article http://www.advancedqtp.com/knowledge-base/qtips/qtp-id18/reports/embedded-screenshot-on-qtp-report/ […]
July 26th, 2008 at 4:19 pm
[…] Rated Embedded Screenshot on QTP Report (4 votes)Reserved Objects as an env. object replacement (3 votes)Working with DOS command line […]
July 31st, 2008 at 9:23 pm
I am most intrigued by this line, wanting to understand what the colon in the middle of it does.
qtp.Visible = False : Wait 0, 500
August 1st, 2008 at 12:08 am
is like a new line in vbscript
August 12th, 2008 at 2:53 pm
Hi,
Can we store all the screenshot generated by QTP in some other file say .xls in sequential manner?
I have seen QTP generating html files for each snapshot but while manually opening, the html file would only display the content and not the images.
Regards,
vishwanath Uppala
August 12th, 2008 at 2:55 pm
Also, i run QTP in windows locked mode to generate screenshots.
August 12th, 2008 at 2:55 pm
hello all,
i have reviewed the code below and found the problem.
here is the code fixed.
the picture then is shown in the report as desired:
Public Sub CaptureScreenshot( ByRef Sender, ByVal micStatus, ByVal descriptionStr )
Dim dateTimeNow, fileNameStr, divDesc, caption
Dim dicMetaDescription, qtp
dateTimeNow = DotNetFactory.CreateInstance( “System.DateTime” ).Now.ToString( “ddMMyyHHmmss” )
‘fileNameStr = Reporter.ReportPath & “\” & dateTimeNow & “.png”
fileNameStr = Reporter.ReportPath & “\” & dateTimeNow & “.png”
Set qtp = CreateObject( “QuickTest.Application” )
qtp.Visible = False : Wait 0, 500
If IsObject( sender ) Then
Sender.CaptureBitmap fileNameStr, True
caption = Sender.ToString & ” - Capture Bitmap”
Else
Desktop.CaptureBitmap fileNameStr, True
caption = “Desktop - Capture Bitmap”
End If
qtp.Visible = True
divDesc = “” & _
“” & caption & “” & _
“Application Exception Description” & _
“” & _
“” & descriptionStr & “”
Set dicMetaDescription = CreateObject( “Scripting.Dictionary” )
dicMetaDescription( “Status” ) = micStatus
dicMetaDescription( “PlainTextNodeName” ) = “ApplicationException”
dicMetaDescription( “StepHtmlInfo” ) = “” & divDesc & “”
dicMetaDescription( “DllIconIndex” ) = 205
dicMetaDescription( “DllIconSelIndex” ) = 205
dicMetaDescription( “DllPAth” ) = EnVironment( “ProductDir” ) & “\bin\ContextManager.dll”
Call Reporter.LogEvent( “User”, dicMetaDescription, Reporter.GetContext )
End Sub
enjoy!!
August 12th, 2008 at 2:58 pm
sorry the code wasnt pasted correctly.
here is:
Public Sub CaptureScreenshot( ByRef Sender, ByVal micStatus, ByVal descriptionStr )
Dim dateTimeNow, fileNameStr, divDesc, caption
Dim dicMetaDescription, qtp
dateTimeNow = DotNetFactory.CreateInstance( “System.DateTime” ).Now.ToString( “ddMMyyHHmmss” )
‘fileNameStr = Reporter.ReportPath & “\” & dateTimeNow & “.png”
fileNameStr = Reporter.ReportPath & “\” & dateTimeNow & “.png”
Set qtp = CreateObject( “QuickTest.Application” )
qtp.Visible = False : Wait 0, 500
If IsObject( sender ) Then
Sender.CaptureBitmap fileNameStr, True
caption = Sender.ToString & ” - Capture Bitmap”
Else
Desktop.CaptureBitmap fileNameStr, True
caption = “Desktop - Capture Bitmap”
End If
qtp.Visible = True
divDesc = “” & _
“” & caption & “” & _
“Application Exception Description” & _
“” & _
“” & descriptionStr & “”
Set dicMetaDescription = CreateObject( “Scripting.Dictionary” )
dicMetaDescription( “Status” ) = micStatus
dicMetaDescription( “PlainTextNodeName” ) = “ApplicationException”
dicMetaDescription( “StepHtmlInfo” ) = “” & divDesc & “”
dicMetaDescription( “DllIconIndex” ) = 205
dicMetaDescription( “DllIconSelIndex” ) = 205
dicMetaDescription( “DllPAth” ) = EnVironment( “ProductDir” ) & “\bin\ContextManager.dll”
Call Reporter.LogEvent( “User”, dicMetaDescription, Reporter.GetContext )
End Sub
August 12th, 2008 at 2:59 pm
again there is a problem pasting the code i will put th code in the forum under the titel “Embedded Screenshot on QTP Report Fixed”
Sorry about that!!
August 18th, 2008 at 6:34 pm
I have tried the above code using QTP 8.2 but could nt capture the screen shot in the test result.Help me in this regard
August 25th, 2008 at 5:52 pm
Public Sub CaptureScreenshot( ByRef Sender, ByVal micStatus, ByVal descriptionStr )
Dim dateTimeNow, fileNameStr, divDesc, caption
Dim dicMetaDescription, qtp
dateTimeNow = DotNetFactory.CreateInstance( “System.DateTime” ).Now.ToString( “ddMMyyHHmmss” )
fileNameStr = Reporter.ReportPath & “\” & dateTimeNow & “.png”
Set qtp = CreateObject( “QuickTest.Application” )
qtp.Visible = False : Wait 0, 500
If IsObject( sender ) Then
Sender.CaptureBitmap fileNameStr, True
caption = Sender.ToString & ” - Capture Bitmap”
Else
Desktop.CaptureBitmap fileNameStr, True
caption = “Desktop - Capture Bitmap”
End If
qtp.Visible = True
divDesc = “” & _
“” & caption & “” & _
“Screenshot as below” & _
“” & _
“” & descriptionStr & “”
Set dicMetaDescription = CreateObject( “Scripting.Dictionary” )
dicMetaDescription( “Status” ) = micStatus
dicMetaDescription( “PlainTextNodeName” ) = “ApplicationException”
dicMetaDescription( “StepHtmlInfo” ) = “” & divDesc & “”
dicMetaDescription( “DllIconIndex” ) = 205
dicMetaDescription( “DllIconSelIndex” ) = 205
dicMetaDescription( “DllPAth” ) = EnVironment( “ProductDir” ) & “\bin\ContextManager.dll”
Call Reporter.LogEvent( “User”, dicMetaDescription, Reporter.GetContext )
End Sub