07-11-2013, 03:27 PM
instead of using this method i will send u the function and how to use that but this code i posted in the articles in the forum if u did not get it i will send u again
to use it in the script just keep the below lines at the top of your script
just place this line where you want to capture the screenshot
write the function which i have written above in a library function and add it to the script
Code:
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 = "<table align='center' border='5' cellpadding='1' cellspacing='1' width='100%' title='" & fileNameStr & "' frame='hsides'>" & _
"<caption>" & caption & "</caption>" & _
"<thead><tr><th>Application Exception Description</th></tr></thead>" & _
"<tfoot><tr><td align='center'><img border='2px' src='" & fileNameStr & "' /></td></tr></tfoot>" & _
"<tbody><tr><td>" & descriptionStr & "</td></tr></tbody></table>"
Set dicMetaDescription = CreateObject( "Scripting.Dictionary" )
dicMetaDescription( "Status" ) = micStatus
dicMetaDescription( "PlainTextNodeName" ) = "ApplicationException"
dicMetaDescription( "StepHtmlInfo" ) = "<DIV align=center>" & divDesc & "</DIV>"
dicMetaDescription( "DllIconIndex" ) = 205
dicMetaDescription( "DllIconSelIndex" ) = 205
dicMetaDescription( "DllPAth" ) = EnVironment( "ProductDir" ) & "\bin\ContextManager.dll"
Call Reporter.LogEvent( "User", dicMetaDescription, Reporter.GetContext )
End Sub
Code:
RegisterUserFunc "Page", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Browser", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Frame", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Dialog", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "swfWindow", "CaptureScreenshot", "CaptureScreenshot"
Code:
Browser("micclass:=Browser").Page("micclass:=Page").CaptureScreenshot micPass, "<h4 align = ""Center"">Page SuccessFully Displayed</h4>"
write the function which i have written above in a library function and add it to the script