Forum Discussion

testcomplete's avatar
testcomplete
Occasional Contributor
16 years ago

How to post custom message to log when checkpoint pass/fail?


Condition ---- visibleonscreen of "page" button property is true --- verified using property checkpoint



Call aqObject.CompareProperty(Aliases.Printgroove_POD_Ready.HwndSource_CPGRMainWnd.CPGRMainWnd.grManinWindowGrid.dpPageAreaPanel.dockManager.Grid.Grid.gridDocking.zpanel.Grid1.Grid.DockablePane.DockPanel.PaneHeader.DockPanel.tbTitle.VisibleOnScreen, cmpEqual, True, False)






.CompareProperty(.Printgroove_POD_Ready.HwndSource_CPGRMainWnd.CPGRMainWnd.grManinWindowGrid.dpPageAreaPanel.dockManager.Grid.Grid.gridDocking.zpanel.Grid1.Grid.DockablePane.DockPanel.PaneHeader.DockPanel.tbTitle.VisibleOnScreen, cmpEqual, , )

3 Replies

  • Hello,


    You can use LogParams Object inside OnLogMessage Event.


    LogParams.Str Specifies the text posted to the test log. (TC Help)

    LogParams.Locked Specifies whether the posting of a message to the test log will be cancelled. (TC Help)


    Here is the sample code


    VB Script

    Sub GeneralEvents_OnLogMessage(Sender, LogParams)

        messageString = "The property value ""True"" equals the baseline value ""True""."

        If LogParams.Str = messageString Then

          LogParams.Locked = True

          Log.Message "My Custom Message"

        End If

    End Sub



    Regards,


  • Hi,





    To Muhammad:





    You should avoid using Log.Message inside the OnLogMessage event handler to avoid recursive calls. The event handler should look like this:







    Sub GeneralEvents_OnLogMessage(Sender, LogParams)

        messageString = "The property value ""True"" equals the baseline value ""True""."

        If LogParams.Str = messageString Then

          LogParams.Str = "My Custom Message"

        End If

    End Sub







    To Amarajothi:





    As an alternative, to post a custom message to the log when a checkpoint passes or fails, you can follow the steps below:

    1. Suppress the log.

    2. Perform a checkpoint and save its result to a variable.

    3. Enable the log.

    4. Post a custom message.





    Here is an example:







      Log.Enabled = False

      Result = aqObject.CompareProperty(Aliases.Printgroove_POD_Ready.HwndSource_CPGRMainWnd.CPGRMainWnd.grManinWindowGrid.dpPageAreaPanel.dockManager.Grid.Grid.gridDocking.zpanel.Grid1.Grid.DockablePane.DockPanel.PaneHeader.DockPanel.tbTitle.VisibleOnScreen, cmpEqual, True, False)

      Log.Enabled = True

      If Result Then

        Log.Message("Page button is visible")

      Else

        Log.Warning("Page button is not visible")

      End If







    Please see the aqObject.CompareProperty help topic for more information.





    BTW, the latest TestComplete version is 8.10.