Ask a Question

onerror save the screenshot of desktop

SOLVED
mustafayol
Occasional Contributor

onerror save the screenshot of desktop

Hi,

 

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.

 

 Sys.Desktop.Picture().SaveToFile("D:\\screenshot")

 

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() {

line1....

line 2...

.

.

.

line 400

 

}

 

With regards

Mustafa

 

4 REPLIES 4
Marsha_R
Champion Level 3

mustafayol
Occasional Contributor

Thank you for your answer. Yes, I tried to use it. After step 3, the procedure to implement the handler to the script is really not clear.

 

  1. 1) Add an Event Control to Your Project
  1. 2) Add Needed Events to the Event Control
  1. 3) Create an Event Handler

53800.jpeg

Should "function EventControl1_OnLogError" be used as the main function to call other test case routines? Like a big try block? 

 

function EventControl1_OnLogError(Sender, LogParams)

{

  testCase1();

testCase2();

.

.

.

testCase10();

}

 

I cannot find any example or demonstration of how to implement an event handler to a script.

Actually, that is a general problem which I really don't like with test complete desktop test module, lack of examples. I do not understand why there is no repository showing how to use a specific function. Please correct me if I am wrong. 

 

 

 

 

 

mustafayol
Occasional Contributor

Yes, I haven't seen it. Ok, I will check it out. Thanks Marsha_R.

.

Best Regards

Mustafa

cancel
Showing results for 
Search instead for 
Did you mean: