Re: Capturing screen shots on error in results window (448 Views)
Reply
Regular Advisor
Posts: 105
Registered: ‎11-17-2009
Message 1 of 13 (450 Views)
Accepted Solution

Capturing screen shots on error in results window

Hi,
I am trying to capture screen shots of the windows application when error occurs in result window. I checked Tools > Options > Run tab check box. And I also made Active screen level as Partial.
NOTE : I am running on a virtual machine from QC.

Thanks
Trusted Contributor
Posts: 348
Registered: ‎09-18-2008
Message 2 of 13 (450 Views)

Re: Capturing screen shots on error in results window

This article explains how to do it:

http://www.advancedqtp.com/community/blogs/embedded-screen-shots-in-qtp-now-working-on-qtp95/

It references an updated version for 9.5. QTP10 has a built in function to save an image to a report but you still have to capture it and reference the file for it to save it. I've altered the function to determine what version of QTP you have and use the appropriate code to get a screenshot in the report.
Regular Advisor
Posts: 105
Registered: ‎11-17-2009
Message 3 of 13 (450 Views)

Re: Capturing screen shots on error in results window

If I use this function I can capture some particular screens that I want. But I would like to capture the screens when error occurs during runtime in results window.
I would like to analyze which button or screen doesn't work by looking at the screenshot.

Thanks
Frequent Advisor
Posts: 67
Registered: ‎03-02-2010
Message 4 of 13 (450 Views)

Re: Capturing screen shots on error in results window

Hi Ashakiran,
Can you score me a point for helping you with the "Accessing Hotkeys" answer that I gave you?
Thank-you

Regular Advisor
Posts: 105
Registered: ‎11-17-2009
Message 5 of 13 (450 Views)

Re: Capturing screen shots on error in results window

I already did.

Thanks
Trusted Contributor
Posts: 348
Registered: ‎09-18-2008
Message 6 of 13 (450 Views)

Re: Capturing screen shots on error in results window

Ashakiran,

What is the result window? Is the the report? This will put a screen shot in the report. So you will have to put in your automation a step on failure to output the screenshot to the report with a log message.

You can output something like:

"Failed to find button 'submit'" and have a screen shot of the application. While examining the screenshot you will see that the application is on the wrong screen, that is why it could not click the submit button.

Regular Advisor
Posts: 105
Registered: ‎11-17-2009
Message 7 of 13 (450 Views)

Re: Capturing screen shots on error in results window

I was refering to the window that you will see at the end of the script reporting where the script is passed or failed.
The results specify which part of the code failed, but its not caputing the screenshot underneath the failed step. I thought I can do this without writing any type of code in my script, using options or settings tab.
I hope I am clear this time.

Asha
Trusted Contributor
Posts: 348
Registered: ‎09-18-2008
Message 8 of 13 (450 Views)

Re: Capturing screen shots on error in results window

Ashkiran,

What version of QTP do you have?

If you have QTP 10 you can do so by using the following command:


fileNameStr = Reporter.ReportPath & "\" & Now() & ".png"
Desktop.CaptureBitmap fileNameStr, True

Reporter.ReportEvent micStatus, reportStepNameStr, descriptionStr, fileNameStr

If you have a version previous to 10 you must use the function referred to in my first post to accomplish what you want. There are certain cases in which a screenshot is automatically created(a checkpoint failing) but not all cases. There is no quick way to accomplish what you want. The code has already been written so all you would need to do is copy it and then use the code in your script.
Regular Advisor
Posts: 105
Registered: ‎11-17-2009
Message 9 of 13 (450 Views)

Re: Capturing screen shots on error in results window

thanks for the response. Currently I am using QTP 9.0. Regarding writing code in my script; should write the code each time I want to capture the screen?
Currently I have 20 resuable actions in one script. Each actions opens multiple screens. For each screen I am reporting if the screen is launched or not. Do I need to write the code for each screen? or can I write in global function for one time?
NOTE : I am not calling gobal function everytime for screen launching.

Thanks
Trusted Contributor
Posts: 348
Registered: ‎09-18-2008
Message 10 of 13 (450 Views)

Re: Capturing screen shots on error in results window

I have the code written once as a function in a function library. You can attach the function library to your test in many ways (executefile, directly adding function library to test, etc.) and then call the function any time you need to use it.

In your case I would attach the function library to the main test. Then in each action call the function to report if the screen was found or not and display the screenshot.
Regular Advisor
Posts: 105
Registered: ‎11-17-2009
Message 11 of 13 (448 Views)

Re: Capturing screen shots on error in results window

Thanks. I will try it. By the way I have one more concern. When another user ran the same script form his machine, he is able to see the screenshots (in results, beside failed action) without writing any type of code. Not sure how. He is using the same script as I am.

Thanks
Highlighted
Trusted Contributor
Posts: 348
Registered: ‎09-18-2008
Message 12 of 13 (448 Views)

Re: Capturing screen shots on error in results window

Can you take a screenshot of your screen(without the screenshot) and his screen(with the screenshot)?

I will say the shortcoming of the code above pre QTP10 is that the image is stored locally on the box. If you upload your report to QTP the screenshot will not show unless you store all screenshots to a shared respository on the network that all users can access.

Please assign points if you feel that my responses were helpful.

Regular Advisor
Posts: 105
Registered: ‎11-17-2009
Message 13 of 13 (448 Views)

Re: Capturing screen shots on error in results window

Can someone please let me know what type of errors does QTP capture as a screenshot in results, when I use Settings -> Run tab, error option.

Thanks
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.