Forum Discussion

msap's avatar
msap
Frequent Contributor
7 years ago

Script to print output pass or fail

can some one please suggest to print output of the line while running the script whether the line ran is pass or fail

Example:  if the button is loaded print pass or else fail.

 

10 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    It will be something like this

    If button.exists then log.message("Pass") else log.message("Fail")

     

    However, the object could be different (not always a button), the state could be different (not always exists), and you didn't tell us which scripting language.  Hard to be more precise without more information.

     

    There are also many events that are already found in the log so some of those might work for you as well.

     

    • msap's avatar
      msap
      Frequent Contributor

      Thanks .I am using Java scripting. other than if else statement, what can I use. I tried to use Log.message. It only prints the message does not specify whether its passed or fail.

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3

        TestComplete will not automatically know if it's passed or failed because it does not know what your conditions are.  We are all testing different things and have different requirements.  You may want to know if the button Exists and I may want to know if it's Visible.  That's what a decision statement like If/Then/Else or Case does for you.

         

        Log.message just puts out a string.  You have to construct the test so it outputs the string you want.