Forum Discussion

vprabhubalu's avatar
6 years ago

Using checpoint is it possible to display customized message in result/logs

Whenever a checkpoint is used in script it always displays the standard message in TestComplete logs .

 

aqObject.CheckProperty(Object, "Enabled", cmpEqual, True)

Result:The property checkpoint passed: Enabled equals True.

 

When using checkpoint Is it possible to Customize the message shown in logs?

 

 

  • Not using that as it is.

     

    What you can do is, instead, use aqObject.Compare property.  This returns a boolean true/false which you can use to drive further code.  It also supports a "MessageType" parameter which you can set to "none" to supporess automatic messages.  Then, what you can do, if the result returns true, use a Log.Checkpoint call to log your own custom message and, if the result returns false, use Log.WArning or Log.Error to log your own custom message.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Not using that as it is.

     

    What you can do is, instead, use aqObject.Compare property.  This returns a boolean true/false which you can use to drive further code.  It also supports a "MessageType" parameter which you can set to "none" to supporess automatic messages.  Then, what you can do, if the result returns true, use a Log.Checkpoint call to log your own custom message and, if the result returns false, use Log.WArning or Log.Error to log your own custom message.

  • I was looking to log a common screen name from the alias of the object as an example of a custom message. So if there is a pattern of how you want to customize, you may be able to do something similar. In the following example, I take the LogParams of the checkpoint event, strip out the object name then do a lookup to a table of Alias to common, human readable name.

     

    I don't know if this example is useful.

     

     

    function GeneralEvents_OnLogCheckpoint(Sender, LogParams)
    {  		 
    
    	var objectName = GetObjectName(LogParams.AdditionalText);
    	LogParams.MessageText = LookUpObjectinProject(objectName) + LogParams.MessageText;
    	
    }

     

    // String maniulation to get the object name of the mapped name
    // RETURN that object name string.
    function GetObjectName(additionalText)
    {
      	// String manipulation gets the name of the object objectName
    	var intPosOne = additionalText.indexOf("<td>") + 4;
    	var intPosTwo = additionalText.indexOf("</a>");
    
    	var objectName = additionalText.substring(intPosOne, intPosTwo);
    	
    	intPosOne = objectName.indexOf(">") + 1;
    	objectName = objectName.substring(intPosOne);
    	// string manipulation to get objectName compelte
    	
    	return objectName;
    }
    // Take name input parameter and look for a common name in the PROJECT VARIABLE that
    // has a 2 column table of object names and their corresponding common human understandable, name.
    // If a common name exists, return it, else an empty string is returned.
    function LookUpObjectinProject(objectName)
    {
    
    	var commonName =  "";
    	// get common name lookup table
    	if (Project.Variables.VariableExists("ScreenObjectCommomName"))  // if the table does not exist, do no translation
    	{
    		var t = Project.Variables.ScreenObjectCommomName;
    		var iterator = t.Iterator;
    		iterator.Reset();
    		while (!iterator.IsEOF())
    		{
    			if (iterator.Value(0) == objectName)
    			{
    				commonName = iterator.Value(1) + " ";
    				break;		
    			}
    			iterator.Next();
    		}
    	
    	}  
    	return commonName;
      
    }

     

    • TanyaYatskovska's avatar
      TanyaYatskovska
      SmartBear Alumni (Retired)

      Thanks for sharing your suggestions, tristaanogre, vthomeschoolm!

       

      vprabhubalu, did these suggestions help you find an answer to your question? Please share your solution with us.