Forum Discussion

mortenb123's avatar
mortenb123
Contributor
6 months ago
Solved

SetText() exception not caught

How can I catch this exception?

function setControlText(control, text) {
    //usage example 1: setControlText(txtUName, userName);
    //usage example 2: setControlText(passwordBox, ("1234[Enter]"));
    Log.Message("text to enter:" + text);
    try {
      clearControlText(control);
      control.SetText(text);
      control.Click(01, 01);
    } catch(e) {
      Log.Message(e.message + " ignored");
    }
}

 It fails at the SetText() line with this error:

Unable to perform the action because the text editor is disabled.    12:07:56    Normal            7.05
  • Not all methods throw an exception, and SetText doesn't throw an exception.

     

    See TestComplete Events, OnLogError Event which can capture the message.