Forum Discussion

mustafayol's avatar
3 years ago

onerror save the screenshot of desktop



I am automating a desktop app by using JavaScript. I want to take the screenshot and save it on the computer whenever the script encounters an error, warning or problem. Currently, testcomplete saves the last screen with error on its script logs, but my aim is to save the error screen on the computer. 

I know there is a method as shown below, but it is useless for me because I have to call it when the error occurs and I do not know when the error occurs.




So in summary, let's say I have 400 lines of code, whenever an error occurs call the above method to save the screen on the computer.

I tried "try and catch" but it doesn't help, as the error we have is not a code error. 

There is a property on the "Execution Plan" test execution window called "on error", but it doesn't have the possibility to call another function. 

It would be great something like, when function encounters an error then call a user-defined function, then I would write a function to take screenshots.


Maybe you would say put assertions like if (!object.exists) { takeScreenshot } but the errors that I have database related and I cannot figure to when to see and what to see. So I need something, whenever I have an error, that causes the script to stop, take the screenshot and save it on computer. 

This is what built-in script logs do, I just want the same thing in my hands, then I can email the error screens to my colleagues externally.



function testDesktopApp() {


line 2...




line 400




With regards



4 Replies