Forum Discussion

Orvai's avatar
Orvai
Occasional Contributor
7 years ago

TestComplete 12.5 - Problem with posting image to testlog

Hello,

 

I'm using Testcomplete 12.5 with vbScript. We had a function for writing log messages to the testlog, which gets a control as an argument and posts it in the Log.Error function as [picture] argument. In the object spy, it has a .Picture method. If I take the control by calling it with Aliases.controlName directly in the Log.Error function, it works.

 

The error message I get by accessing the Err.description attribute is: "Could not convert variant of type (ByRef Variant) into type (Dispatch)"

 

It worked in 12.4. Is there an error in TestComplete, or is there another way to post images of controls to the testlog? We have written a test framework with a lot of function, we are accessing Controls via variables all the time.

 

Best regards,

Christoph

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Can you share the code that generates the error?  It would be useful to see how you are implementing what you're doing.  

  • Orvai's avatar
    Orvai
    Occasional Contributor

    Hello,

     

    I am accessing the control like this:

     

    Set TestTool = Aliases.TestTool

    Set MyControl = TestTool.myControl

     

    Then I use a method like: MyLog.LogMessage("An error occured", pmHigher, "", MyControl)

     

    In this method I call the standard log function:

     

    sub LogMessage(message, priority, attributes, control)

        Dim MyImage

        MyImage = control.Picture

        Log.Error(message, priority, attributes, MyImage)

    End Sub

     

    I also get the error if I get the control by calling:

    Set MyControl = TestTool.WaitAliasChild("myControl")

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Understanding that this used to work before... note that Log.Message has more parameters than you are using.  So....  what you are passing in as priority is actually the parameter for "Additional Info", attribs is actuallyl priority, and where you have your control is actually the attribs.  

       

      What happens if you change your code to this:

      sub LogMessage(message, priority, attributes, control)
      
          Dim MyImage
      
          MyImage = control.Picture
      
          Log.Error(message, "", priority, attributes, MyImage)
      
      End Sub
      • Orvai's avatar
        Orvai
        Occasional Contributor

        Hi tristaanogre,

         

        indeed my code already is like you suggested, I missed the 'additional Info' attribute in my example. I'm sorry.

         

        Best regards

        Christoph