Forum Discussion

agmuntianu's avatar
agmuntianu
Occasional Contributor
13 years ago

Open Log after TestExecute has finished a test, when it is being called via COM

Hello everyone,



As you can see from the thread title I am trying to display the log result of the test (in IExplorer) after the test finishes.

If I start the test using TE directly , the results are displayed automatically, but this doesn't happen when I start the test via COM.

My initial approach was to start the test and using the Log object, get the path to the log file generated (mht) , and afterwards to open a I Explorer window with that file as parameter. Unfortunately I cannot seem to find a path to get that object (I am developing using Visual Studio C# Express 2010).

In the help manual there is a reference to this matter, I quote : 



To obtain a program object...
To obtain program objects such as Sys,
Log,
Runner,
Regions
and others, use the GetObjectByName
method of the Integration object.







You can obtain the object only if TestComplete is running
a test. If there is no tests running in TestComplete,
GetObjectByName will return an empty Variant value.



Until now I was not able to get a reference to the Log Object.



My questions are :

1. Is there a mechanism through which the log can be displayed after a test finishes when the TestEecute is being called via COM other than my approach?

2. How can I get access to the Log Object via COM, the documentation is scarce to say the least ....?



Thank you in advance,

BR Andrei. 

6 Replies

  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Andrei,




    1. Is there a mechanism through which the log can be displayed after a test finishes when the TestExecute is being called via COM other than my approach?



    Unfortunately, I don't know another approach.




    2. How can I get access to the Log Object via COM, the documentation is scarce to say the least ....?



    The fact is that the Integration object is TestComplete's program object, so you can find information about it in the TestComplete online help. For details, see the Integration.GetObjectByName help topic.


    For example, you can try using something like that:



    Integration.GetObjectByName(Log).SaveResultsAs("D:\MyResults.mht", lsMHT, true)



    After that, you need to open the web browser and navigate it to the D:\MyResults.mht URL.


    Another important note: the code line I've mentioned will work correctly only in one case, when TestComplete is executing a script test, while you are trying to access the SaveResultsAs method of the Log object. Otherwise, TestComplete may behave unexpectedly.

  • agmuntianu's avatar
    agmuntianu
    Occasional Contributor
    Hi Irina



    Thank you for your suggestion. I have tried it , but the problem that I am now facing is that the function GetObjectByName called on a integration object , will generate a general object and I am not able to run on it the SaveResultsAs function.

    I get the following error 




    "Error 1 'object' does not contain a definition for 'SaveResultsAs' and no extension method 'SaveResultsAs' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) C:\AGM\My Documents\Visual Studio 2010\Projects\FrontEndToTestComplete\FrontEndToTestComplete\Form1.cs 323 70 FrontEndToTestComplete "




    Any idea on somehow bypassing the compiler's checks ?



    Thank you in advace



    BR, Andrei.
  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Andrei,


    It looks like you're trying to call the SaveResultsAs method of the Log object when the script execution is over. I would like to mention one more time that you can call this method via the Integration object only when the script for which you're trying to save the results is running in TestComplete.


    If you call the SaveResultsAs method when the script execution is over, TestComplete cannot access this method. That's why your application may show the error message you've mentioned.


    Could you please clarify why you need to access this method via COM? It is much easier to save the results directly from TestComplete script using the Log.SaveResultsAs() method. Why can't you do that?


    Thanks.

  • agmuntianu's avatar
    agmuntianu
    Occasional Contributor
    Hi Irina,



    The error I pasted in the previous reply was not after the execution, it was while I was trying to compile the code, my guess is C# has safeguards that prevent calling function that are not declared for a certain object , and because I use the GetObjectByName function to get that object, which I don't declare specifically, because I cannot find an COM object that points to Log object in TC.



    BR. Andrei.
  • agmuntianu's avatar
    agmuntianu
    Occasional Contributor
    Hi again,



    To answer your question regarding the reason for using the COM objects from within C#. I am trying to build a wrapper to TestExecute , which would allow a end user to start only certant tests from within the project suite , without the aid of TestComplete, also the wrapper should implement additional features that cannot be implemented in TestComplete/TestExecute .



    BR. Andrei.
  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Andrei,


    I am trying to build a wrapper to TestExecute


    I'm afraid, you understand the purpose of implementing the GetObjectByName method in TestComplete incorrectly. This method lets you access run-time objects of TestComplete from Connected Applications. You cannot use this method while building the application.


    For more information, see the Creating Connected Applications in C# help topic.