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

While running my tests, i get some unexpected Errors like " Error found click here to go back " . for this situation i added a recovery senario. but my requirement is can i capture or make a note of such errors to confirm that error has occured/exists . Also is there any option to check after which step it occured?
Reply
#2
Solved: 11 Years, 4 Months, 2 Weeks ago
U can capture the screen shot for the error.
Use this in the recovery scenario u had created, and save at desired location.

Code:
Desktop.CaptureBitmap(Imagename,True)

Correct me if wrong

Regards,
Sankalp
Reply
#3
Solved: 11 Years, 4 Months, 2 Weeks ago
If i Write this line "Desktop.CaptureBitmap(Imagename,True)" at the start or end of the script will it capture all the errors and save in required loaction or i have define this every time through out the script?
Image name here is the one which we save in recovary scenario?
Reply
#4
Solved: 11 Years, 4 Months, 2 Weeks ago
Desktop.CaptureBitmap(Imagename,True) will take the screen shot of the current active screen.
If its an error msg box it will capture it.
So its better 2 use it in recovery scenario.
When error occurs recovery scenario will triggers and this will capture the screen shot of the error.

Correct me if wrong

Regards,
Sankalp
Reply
#5
Solved: 11 Years, 4 Months, 2 Weeks ago
HI,
The method suggested by you to include the screenshot code in the function invoked by recovery scenario is just taking the screenshot of the QTp window without the runtime error window.
I am unable to figure out how to take the screenshot of the runtime error window (thrown due to object identification failing) and save it in a location. I am able to invoke my recovery scenario and call the function (below is the code for the function called by the recovery scenario):

Code:
Function RecoveryFunction1(Object, Method, Arguments, retVal)

path_error_file="C:\automation\qtp_screenshot\screenshot_app.png"
Desktop.CaptureBitmap path_error_file,True
Reporter.ReportEvent micFail,"Recovery scenario invoked","Recovery scenario invoked due to runtime error", path_error_file
End Function


But unfortunately its not takeing the screenshot of the runtime error window.
Can anyone pls help!!!
Thanks
Akankhya
Reply
#6
Solved: 11 Years, 4 Months, 2 Weeks ago
Go to tools--->options--->Run-->ScreenCapture then select the check box "Save still image captures to result" and choose "for errors and warnings" in dropdown
you will then see the Error snapshot in the result file generated.
Reply
#7
Solved: 11 Years, 4 Months, 2 Weeks ago
hiii.
I am facing same problem.
I want application screenshot along with error message that QTP/UFT popup showing(screenshot of error message)
Please help me
Thank you
Reply
#8
Solved: 11 Years, 4 Months, 2 Weeks ago
@ ravi.gajul

Not showing error popup
Only showing application screenshot
Reply
#9
Solved: 11 Years, 4 Months, 2 Weeks ago
I doubt in your case whether this would work.This is mainly for object based errors and checkpoints.However, if you are using QTP 9.5 or above, you have an option to save the entire test run as a movie. It definitely is an overhead in terms of space and performance but it really helps when debugging becomes a nightmare.
Reply
#10
Solved: 11 Years, 4 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


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

Forum Jump:


Users browsing this thread: 2 Guest(s)