Forum Discussion

ASV's avatar
ASV
Contributor
14 years ago

How to convert Log error to Log message

I need to convert Log error to message. I need this because I have an object that not exist and it is exact that is not exist but in Log I receive error.

Thanks

4 Replies

  • ASV's avatar
    ASV
    Contributor
    Other example. I write Call wMainForm.PopupMenu.Check("operationname", False). If "operationname" is not exist I receive Log error. But I want to receive log message, because in some cases it is right that "operationname" is not exist.

    Thanks:)


  • Hello Vahagn,





    I need this because I have an object that not exist and it is exact that is not exist but in Log I receive error.














    TestComplete has a set of special methods that you can use to check whether an object exists. Please refer to the Checking Whether an Object Exists help topic to learn more.





    I write Call wMainForm.PopupMenu.Check("operationname", False). If "operationname" is not exist I receive Log error.














    It is not a good approach to prohibit posting an error in such a case. I recommend that you create a helper function that will check whether a specific menu item exits.  Here is a simple example that works with Notepad:





    Function MenuItemExists(menu, caption)

      MenuItemExists = False

      For i = 0 to (menu.Count - 1)

          If aqString.Compare(menu.Items(i).Caption, caption, False) = 0 Then

              MenuItemExists = True

          End If

      Next 

    End Function









    Sub Test

      Dim edit

      Set edit = Sys.Process("notepad").Window("Notepad", "*").Window("Edit")

      Call edit.ClickR(115, 116)

      If MenuItemExists(edit.PopupMenu, "Paste") Then

          Log.Message("The menu item exists")

      Else

          Log.Message("The menu item DOES NOT exist")

      End If

    End Sub


  • ASV's avatar
    ASV
    Contributor
    Thank you very much. It works fine. But for popupmenu I have the same problem(The submenu is opened again), which I describe in thread "Problem with popupmenu".