Forum Discussion

lansanniu's avatar
lansanniu
Occasional Contributor
12 years ago

【help】catch exception in jscript


there is the js code below, I want to catch the ClickButton() exception, and go into the catch{} ,but I fail.

I found  js can catch the error  cause by  itself, such as "alertt "  (the correct is "alert"),

can not catch the error cause by TC9 item.

in a word , I hope I can catch any error ,and go into catch{}



---------------------------------------------------------------------------------------------

function Test1()


{


  try{


Aliases.Xpoms_61.MainWindowRibbon.xtraTabControl.SOM_FundsManage_CashReserveRatio_CashReserveRatio.CashReserveRatio.groupControl1.btnModify.ClickButton();


  }


  catch(err){return "error";}


}

2 Replies

  • lansanniu's avatar
    lansanniu
    Occasional Contributor
    ok,,,i've found the answer myself

    use event [OnLogError], it can be triggered when an error message is posted to the test log.



    --------------------------


    function GeneralEvents_OnLogError(Sender, LogParams)


    {


      return_value = "ERROR";


    }

  • lansanniu's avatar
    lansanniu
    Occasional Contributor
    ps:

    【Aliases.Xpoms_61....ClickButton()】      here ,is an error action I made on purpose. I expect  that it can step into catch{} statement