UFT Takes the Screenshot of Application


'*******************************************Function*********************************
'Author:-              Vishweshwar Reddy
'Function Name:-        fn_TakeScreenShot
'Function Description:- Takes the Screenshot of Application
'Input Parameters:-     Failure Step
'Output Parameters:-    None
''***********************************************************************************
Public Function fn_TakeScreenShot(sReportStep)
'Creating the Screenshot Name
Dim sScreenshotName
sScreenshotName = Environment("ActionName")&"_"& Right("0" & Day(Date), 2) & Right("0" & Month(Date), 2) & Year(Date) & "_" & _
Right("0" & Hour(Now), 2) & Right("0" & Minute(Now), 2) & Right("0" & Second(Now), 2)
'Taking the Screenshot and saving as .png in temporary location
Desktop.CaptureBitmap sReportingPath & "\" & sScreenshotName & ".png", True
'TypeParagraph method to Inserts a new, blank paragraph.(Enter Key)
objWordDoc.Selection.TypeParagraph
'Inserting BOLD Text before the screenshot
 objSelection.Font.Bold = True
 objSelection.TypeText "Step Name:"&sReportStep
 objSelection.Font.Bold = False
 'Adding screenshot to the document
 objSelection.InlineShapes.AddPicture sReportingPath & "\" & sScreenshotName & ".png"
 'Deleting the temporarly saved screenshot .png file using objFSO object
 objFSO.DeleteFile sReportingPath & "\" & sScreenshotName & ".png"
 fn_TakeScreenShot = fn_TakeScreenShot
End Function

Comments

Popular posts from this blog

UFT File Types and File Extensions

QTP/UFT Version History

Synchronization in UFT