Inserting Snapshots in Test Results QTP

This section describes various ways of inserting screen snapshots into the Test Results.

Method 1
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.

Inserting Snapshots in Test Results

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.

Method 2

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

Method 3

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_" &currentTime& ".png"

Desktop.CaptureBitmapsFile
'Insert the above file as a IFRAME in the report
sHTML = "&lt; <IMG Width=""l00%"" src=File: //" &sFile& """></IMG>&gt "
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 © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

QTP Topics