Forum Discussion

BrandonH's avatar
BrandonH
Contributor
8 years ago

Checking the success of a clickButton action

Hi,        I'd like to test whether a series of button clicks was successful (i.e. were all the objects found and successfully clicked).  I first attempted this by putting them in a try/catch state...
  • tristaanogre's avatar
    8 years ago

    try/catch only catches code exceptions.  Object not found errors are not trapped by code try/catch logic.

     

    To that end, I would use, for each button, a "WaitAliasChild" call to detect if the button exists.  Then, if it exists, call the ClickButton action on it.  After the ClickButton is executed, do another check of some sort to detect if the results of the button click worked.  Something like this:

    function testMyButton(){
        var myButton;
        myButton = Aliases.myApp.MyForm.WaitAliasChild('MyButton', 10000);
        if (myButton.Exists) {
            myButton.ClickButton();
            if (newTextField.Text != 'It Works') {
                 Log.Error('MyButton click button failed');
            }
        }
        else {
            Log.Error('MyButton does not exist');
        }
    }