Changing log messages' appearance

If you are unhappy with the standard font style and color in the log, they can be changed with the help of the log's attributes. In this recipe, we will deal with outputting the message with changed parameters for the font.

How to do it...

To post a message with a different style perform the following steps:

  1. Create a new object with the help of the Log.CreateNewAttributes method and change the following parameters: Bold, FontColor, and BackColor in the following manner:
    var attrBoldBlue = Log.CreateNewAttributes();
    attrBoldBlue.Bold = true;
    attrBoldBlue.FontColor = clWhite;
    attrBoldBlue.BackColor = clBlue;
  2. Now we will evoke the method of Log.Message and, with the fourth parameter, we will pass the created variable of attrBoldBlue to it:
    Log.Message("Customized message", null, pmNormal, attrBoldBlue);

    In the result, the message will get outputted into the log as follows:

    How to do it...

How it works...

With the help of the attributes, we can change the color of the fonts and the background (the properties FontColor and BackColor) and the text decoration (Bold, Italic, Underline, and StrikeOut).

In TestComplete, there is a set of supported standard font colors (such as clWhite and clBlue), which can be used as settings for the font and background color. Similarly, it is possible to change the text display style for other types of messages (errors, warnings, and so on) also.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.189.186