Nformation
10 years agoContributor
Try-Catch for Click Methods
I've written a jscript function for closing my application at the end of every test. It first tries to close the application by clicking buttons and, if that fails, calls the Close method.
If the script fails to close the application through the UI, I don't want to log an error--just a warning. However, the script throws an error anyway. I tried surrounding in a Try/Catch, but I've learned that doesn't work with the TestComplete operations I'm performing. How should I go about this?
Here's my script:
try { Aliases.Informa_Cashiering_Client.CurrentTransaction.ApplicationWindow.Grid.FloatingContainerBorder.Grid.FloatingContainerHeader.Grid.stackPanel.Button_CloseApplication.ClickButton(); } catch (e) { Log.Warning("Unable to close through the UI"); } if(myProcess.Exists){ myProcess.Close(1000); }