cancel
Showing results for 
Search instead for 
Did you mean: 

Desktop Scripting - How to throw an error

SOLVED
Gone2TheDogs
Occasional Contributor

Desktop Scripting - How to throw an error

Hello! I'm brand new here! Love this tool but I must convince my company based on a proof of concept. 

 

So, my simple question is, how do you throw an error based on your own test?

 

  GridCellValue = Aliases.Purchasing.frmPurchasingMenu.MdiClient.frmPoShipDateMaint.pnlData.tabMain.tpgTracking.RadGroupBox5.dgvTracking.wValue(0,2)  'row, column
  If GridCellValue <> "167 AAA Cooper" Then
    'throw an error  
  End If
  
  GridCellValue = Aliases.Purchasing.frmPurchasingMenu.MdiClient.frmPoShipDateMaint.pnlData.tabMain.tpgTracking.RadGroupBox5.dgvTracking.wValue(1,2)  'row, column
  If GridCellValue <> "1234567890" Then
    'throw an error  
  End If

 

1 ACCEPTED SOLUTION

Accepted Solutions
BenoitB
Community Hero

Re: Desktop Scripting - How to throw an error

2 ways :

 

- Javascript basis;

 

 throw Error("This is the message of the error")

 

It will generate an exception and you can manage it in single endpoint with try .. catch pattern.

 

Note: you don't have to make throw new Error()  because new is implicit.

 

- TestComplete basis (not really throwing error but sort of);

 

Log.Error("This is the message of the error")

 

 

 

Un sourire et ça repart

View solution in original post

2 REPLIES 2
BenoitB
Community Hero

Re: Desktop Scripting - How to throw an error

2 ways :

 

- Javascript basis;

 

 throw Error("This is the message of the error")

 

It will generate an exception and you can manage it in single endpoint with try .. catch pattern.

 

Note: you don't have to make throw new Error()  because new is implicit.

 

- TestComplete basis (not really throwing error but sort of);

 

Log.Error("This is the message of the error")

 

 

 

Un sourire et ça repart

View solution in original post

tphillips
Community Leader

Re: Desktop Scripting - How to throw an error

For some additional information, the difference between throwing a Javascript error and using Log.Error() is that if you use Javascript's throw keyword you can catch those errors in a try... catch statement, which might be useful in some circumstances. Log.Error() can't be caught by a try... catch statement.


--------------------
QA Systems Architect
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors