Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Capture screen shot for unexpected Errors.
#10
Solved: 10 Years, 8 Months, 2 Weeks ago
@ 'uma87'


you should start with following code
Code:
RegisterUserFunc "Page", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Browser", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Frame", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "Dialog", "CaptureScreenshot", "CaptureScreenshot"
RegisterUserFunc "swfWindow", "CaptureScreenshot", "CaptureScreenshot"
use the following line where you want take screenshot or snapshot
Code:
Browser("micclass:=Browser").Page("micclass:=Page").CaptureScreenshot micPass, "<h4 align = ""Center"">Page SuccessFully Displayed</h4>"
The below code is a library file. Add the library file 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 )
    dicMetaDescription("User") =  EnVironment ("dicMetaDescription")
    dicM
End Sub
Reply


Messages In This Thread
RE: Capture screen shot for unexpected Errors. - by vinod123 - 11-03-2014, 03:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using QTP to capture screen shot ravi.gajul 12 75,625 08-10-2017, 06:58 AM
Last Post: pauljo.kld@gmail.com
  Test Director Errors Autobot 0 1,695 10-23-2015, 10:21 AM
Last Post: Autobot
  Run time errors in SAP when QTP running dverlaque 3 5,244 07-25-2012, 11:26 AM
Last Post: Ankesh
  Unexpected file Format vinayaksarode 3 6,503 01-30-2012, 09:49 PM
Last Post: ravi.gajul
  Getting unexpected Pop up message while using Datatable.import Punam K 2 3,845 08-20-2011, 08:48 PM
Last Post: Arul

Forum Jump:


Users browsing this thread: 1 Guest(s)