Forum Discussion

ushureddy's avatar
ushureddy
New Contributor
11 years ago

How to use " If Then " Statement in testcomplete using javascript

Here the scenario: In a form during some operation calendar having a button is displayed. so I have to first check whether that button is displayed,If yes then I have to click on it to continue. Else continue other operations.





Appreciate the help on this asap.





Thanks,

Usha







  • NisHera's avatar
    NisHera
    Valued Contributor
    Hi,

    To add to above, if you use button.Exists , will give you error when button is not there.

    to avoid an error you can use waite property 

    eg

    function abcd(){

    if (....button.WaitProperty('Exists',true,300)&&......button.WaitProperty('visible',true,200) ) {


      Log.Message('OK');


      //and u r stuff


      } else {


      Log.Message('no button');


      //u r next suff


      }


    }

  • Hi there,



    You can try something like:



    //JScript

    if(<button>.Exist && <button>.Visible){

      //Click the button here

    }

    else {

        //Do something here if the button is not there

    }



    Regards,

    Altus