Forum Discussion

NicolaFilosa_SE's avatar
NicolaFilosa_SE
Contributor
3 years ago

If cycle

Can someone explain me how it is managed the "if cycle" in TestComplete? Because if the "if" condition is false TC gives me an error message instead of passing to the "else" condition

  • If you want your code to continue without TC stopping on error, then change Project Settings to 'On error: Continue running'

     

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    If you want your code to continue without TC stopping on error, then change Project Settings to 'On error: Continue running'

     

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Are you able to provide example code, where TC gives you the error?

    • NicolaFilosa_SE's avatar
      NicolaFilosa_SE
      Contributor

      if(aqObject.CheckProperty(EWApplication.dlgSelectTarget.btnChange, "Enabled", cmpEqual, false))
      {
      EWApplication.dlgSelectTarget.btnCancel.ClickButton();
      delay(5000)
      }
      else
      {
      EWApplication.dlgSelectTarget.ListBox.ClickItem("FreeAdvance 596.13");
      delay(5000)
      EWApplication.dlgSelectTarget.btnChange.ClickButton();
      delay(5000)
      EWApplication.dlgEliwellFreeStudioPlus.btnS_.ClickButton();
      delay(5000)
      }

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    If your btnChange is disabled, then your statement aqObject.CheckProperty(EWApplication.dlgSelectTarget.btnChange, "Enabled", cmpEqual, false) will return true - as noted in the Return Value "True if the property value matches the specified condition and False otherwise."

     

    Ideally, this statement would be better to use, based on the state of btnChange,

     

    function test()
    {
        if (EWApplication.dlgSelectTarget.btnChange.Enabled) {
            Log.Message("Button is enabled");
        } else {
            Log.Message("Button is disabled");
        }
    }

     

     

    • NicolaFilosa_SE's avatar
      NicolaFilosa_SE
      Contributor

      If the condition is verified, so if the the button is disabled and so the condition true, I've no problem. But if the condition is not verified, so the button is enabled, the cycles does not go on the else condition but the script stops because of the error. I have to build a cycle that disciminates between the button enabled/disabled and then do one thing or another. How can I prevent the cycle to stop because of the not verification of the if condition?