Forum Discussion

bharat_sethi's avatar
bharat_sethi
Occasional Contributor
8 years ago
Solved

Get to know the last operation status in script

Hi All,

 

I need to know the status of the last operation performed in script to report to third party such as

 

was that last click operation was sucessful or had failed ?

was that last set operation was sucessful or had failed ?

 

Is there any way i can read the logs for last step as in logs we get status of each step.

 

I tried Project.Logs but does not give me info about the last step 

 

set logitem = Project.Logs.LogItem(Project.Logs.LogItemsCount-1)
set data = logitem.data(logitem.DataCount-1)
status= logitem.Status

 

Please suggest if we have any way.

 

Thanks,

Bharat Sethi

  • Project.Logs only gives you a collection of top level items in the log.  If what you are looking for is not at the top level (Keyword Test, Test Item, Script, etc), that's not going to work for you.

     

    Question: How are you writing out the status in the first place?  Are you just using what TestComplete automatically records or are you writing your own log message for pass/fail on the last operation?  My suggestion would be to do the latter... update your tests/scripts, in such a way that you write out pass/fail results to some sort of storage (in memory variable, external file, database, etc) that you can then mine for the necessary data.

    The other possibility would be to leverage the OnLogEvent message since that fires for each Keys, Click, or SetText call.  I think you can then use that as a jumping off point to find the necessary status.

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Project.Logs only gives you a collection of top level items in the log.  If what you are looking for is not at the top level (Keyword Test, Test Item, Script, etc), that's not going to work for you.

     

    Question: How are you writing out the status in the first place?  Are you just using what TestComplete automatically records or are you writing your own log message for pass/fail on the last operation?  My suggestion would be to do the latter... update your tests/scripts, in such a way that you write out pass/fail results to some sort of storage (in memory variable, external file, database, etc) that you can then mine for the necessary data.

    The other possibility would be to leverage the OnLogEvent message since that fires for each Keys, Click, or SetText call.  I think you can then use that as a jumping off point to find the necessary status.

    • bharat_sethi's avatar
      bharat_sethi
      Occasional Contributor

      Thanks Robert,

       

      OnLogEvent has solved my problem.

       

      Still to elaborate where and why this problem started :

       

      In our framework, Test team is writing the test cases in test management tool in plain English and using out translation engine we translated those English statement in to steps and was looking for status of each step whether it failed or passed to feed it back to Test management tool.

        

      How are you writing out the status in the first place?- we wehere assuming the step executed sucessfully. ie. i said to click it we have assumed we have clicked and next step will fail due to next action can't be performed if this action is depedent of previous action :(

       

      Are you just using what TestComplete automatically records or are you writing your own log message for pass/fail on the last operation?  - we were writing our own log messages in file from where we were updating the results back in test management tool.

       

      Now we can read the status streight away from test complete logs and push it back.

       

      Thanks,

      Bharat

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        IF it works, it works.  Good to know. :)

        Just a note, the way I handle the same thing in my own framework construction is that each test step that comes from the external file is executed and returns either a boolean true or false.  As I'm looping through steps, I check that value.  True = success, false = failure. I can then report directly there without having to worry about tracking TestComplete's logging.  I know this is probably going to be a LOT of work for you to retrofit but, if you ever get to a re-factoring stage of your framework, worth looking into.