TestComplete 8 Sneak Peek: Posting HTML Messages to the Log

Messages that you post to the test log contain the basic text that is shown in the messages list and an extended part that is displayed in the Remarks panel of the test log. In TestComplete 8, the extended portion of your messages can be in the HTML format. This feature lets you post extended messages that support various font styles, tables, lists and other formatting provided by HTML.

To apply the HTML format to the extended messages, simply add the <html>…</html> tags to the StrEx parameter of the methods that post messages to the log. For instance, the following code demonstrates how you can post a message containing bold text:


' VBScript

Log.Message "Log Message", " <html> <body><p> This is my <b>HTML</b> message. </p> </body> </html>"
// JScript

Log.Message ("Log Message ", "<html><body><p>This is my <b style="color : green">HTML</b> message. </p> </body> </html>");
// DelphiScript

Log.Message(' Log Message ', ' <html> <body> <p> This is my <b style="color: green;">HTML</b> message. </p></body></html>');
// C++Script, C#Script

Log["Message"] ("Log Message", "<html><body><p>This is my <b style="color : green">HTML</b> message.</p></body></html>");

The test log will determine that the StrEx parameter contains HTML code and will display it in the Remarks panel:

The "old" text format is also supported. If the StrEx parameter does not contain the <html>…</html> tags, the Remarks panel will display the extended part of the log message as text.

Sometimes you may need to post the HTML code to the log as plain text. To do this, use the new ExtendedMessageAsPlainText property of the LogAttributes program object. When this property is True, the extended text of a test log message will be displayed in the Remarks panel as plain text. The following code demonstrates how you can post HTML code to the log:

' VBScript

Set Attrs = Log.CreateNewAttributes

Attrs.ExtendedMessageAsPlainText = True

Log.Message "Log Message", "<html><body><p>This is my <b style=""color : green;"">HTML</b> message.</p></body></html>", pmNormal, Attrs
// JScript

var Attrs = Log.CreateNewAttributes();

Attrs.ExtendedMessageAsPlainText = true;

Log.Message ("Log Message", "<html><body><p>This is my <b style="color : green">HTML</b> message.</p></body></html>", pmNormal, Attrs);
// DelphiScript

var

Attrs : OleVariant;

begin

Attrs := Log.CreateNewAttributes();

Attrs.ExtendedMessageAsPlainText := True;

Log.Message('Log Message', '<html><body><p>This is my <b style="color: green;">HTML</b> message. </p></body></html>', pmNormal, Attrs);

end;
// C++Script, C#Script

var Attrs = Log["CreateNewAttributes"]();

Attrs["ExtendedMessageAsPlainText"] = true;

Log["Message"] ("Log Message", "<html><body><p>This is my <b style="color : green">HTML</b> message.</p></body></html>", pmNormal, Attrs);

HTML code in the test log

We hope you enjoy this new improvement. If you are interested in trying TestComplete 8, be sure to apply for the Beta version.


Close

By submitting this form, you agree to our
Terms of Use and Privacy Policy

Thanks for Subscribing

Keep an eye on your inbox for more great content.

Continue Reading

Add a little SmartBear to your life

Stay on top of your Software game with the latest developer tips, best practices and news, delivered straight to your inbox