How do I add my own custom log entries to the Result?
|A Script can post custom log entries to the Result for the Test Composition.
You can place such Scripts within your Test Clips at the points where you wish to generate log entries.
You can also generate custom log entries from your Scripts which output debugging information, either to debug the Script itself, or to debug other portions of the Test Composition. Such debug logging could be conditionally enabled through the use of a Global Property – see the question "How do I parameterize a Test Composition (or its components) so that I can change the behavior each ..." for further information about using Global Properties for such purposes.
|A Script posts log entries to the Result by calling the "postMessage" method of the Result object:
The above example posts a log entry with the text My message.
|Title text is limited to 255 characters. An optional third parameter may be given to specify "detail" text for the log entry. Detail text may be long and consist of multiple lines:
The above example posts the following log entry:
|The log entry may be posted at any of the supported levels, and will be logged only if the logging level for Scripts is set for the Test Composition such that entries of that level are to be logged:
The logging levels for the Test Composition are set in the "Logging" tab in the Composition Editor:
|An In Situ Substitution Expression (ISSE) can also be used to post an entry to the Result, because an ISSE can contain a Scripting expression. For more information on ISSEs, refer to the separate question "How do I dynamically or programmatically substitute a value into a Message or Browser Action before ..." or to the ISSE documentation, for more information on ISSEs.
Although generally intended to be used to insert a value into a Message or Browser Action, if an ISSE contains Scripting it can also have the side effect of creating log entries. If the ISSE returns no value to be inserted into the Message or Browser Action, then effectively its entire purpose could be to generate a log entry before the Message is sent or the Browser Action is executed.
|An example of this is shown here. Because of screen size limitations the entire ISSE is not visible, however the contents of the "inputValue3" field are: