This section describes various ways of inserting screen snapshots into the Test Results.
Configure QTP to save a screen snapshot for every step. Go to Tools→ Options →Run (Tab) and set the option for "Save step screen capture to results:" to "Always" as shown in the Figure.
This is a disk intensive option when the script contains even a modest number of steps, as each screenshot taken increases the size of the results folder.
In this approach we use the SnapshotReportMode setting. This allows us to selectively determine when a snapshot is captured. The trick here is to use the Exist method on the object's whose snapshot needs to be captured:
'Save the old mode
oldMode = Setting("SnapshotRepot Mode")
Setting("SnapshotReportMode") = 0
'To capture a window use the below statment
x = Window("titles =Rurt") .Exist(0)
'To capture a browser use the below statment
x = Browser(""Micclasss :=Browser") .Page("Micclass: =Page") .Exist(0)
'Restore the old mode
Setting("SnapshotReportMode") = oldMode
This approach saves an explicit snapshot using the CaptureBitmap method in the Test Results folder. After adding the snapshot we also add an HTML image tag to the results to display the image.
'Create the html file path
'store it in report folder
currentTirae = Replace(Replace(Replace(now(),":","_"),"/","_") ,'* ","_'")
sFile = Reporter.ReportPath& "Srtap_" ¤tTime& ".png"
'Insert the above file as a IFRAME in the report
sHTML = "< <IMG Width=""l00%"" src=File: //" &sFile& """></IMG>> "
Reporter.ReportEventmicPass, "Snapshot", sHTML
NOTE: Problem with using above approach is that we use absolute file path for the image. So when the test results folder is transferred to any other location, the above path will become invalid and the test results would become invalid. Unfortunately QTP does not provide any way pf using Relative paths for such situation.
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.