Forum Discussion

anik_cadieux's avatar
anik_cadieux
Contributor
10 years ago

Can we change project properties at run time (Playback, Post Image on Error) ?

Hi,



Usually, I want the option "Post image on error" turned ON (located in the Playback section of the project properties). But at a point during my test, I parse through an excel file and check the status of 1000 files. When many of them fail, the screen captures are of no use, and the log at the end weights a lot (around 75MB instead of 8MB).



How can we change this option during playback or run time ?

The only thing I found was this page: http://support.smartbear.com/viewarticle/55021/#Run



Any plans of developping more read/write options ?



Thank you,

Anik



9 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Anik,



    > And we can't do log.error in the On_LogError event...



    Actually, you can at the cost of introduction another boolean public variable.

    VBScript pseudocode:

    Dim boolInLogErrorHandler : boolInLogErrorHandler = False

    ...



    Sub OnLogError()

      If (boolInLogErrorHandler) Then _

        Exit Sub



      boolInLogErrorHandler = True

      ...

      Call Log.Error(...)



      boolInLogErrorHandler = False

    End Sub
    • anik_cadieux's avatar
      anik_cadieux
      Contributor

      Hi AlexKaras,

       

      We fell into this problem again.

      Although the code you provided, we are still unable to manage the "post image on error" functionality.

      Do you have any idea if the new TC 10 provide a way to control such Project Properties ?

       

       

      Thank you!

      Anik

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Anik,

     


    It's impossible to change this option at run time. However, you can create your own function to post an image to the Test Log and call it from any place when executing the test. For example, you can call this function from the OnLogError event handler.


    Here is the sample in JScript:




    function postImage()


    {


     var picture = Sys.Desktop.Picture();


     Log.Picture(picture, "Some text");


    }




     

  • Thank you Tanya for the reply.



    But we don't need to post image on error, we want to stop posting on error for a specific part of the test...



    It would be a nice feature request :)
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Anik,

     


    You can set the LogParamsObj.Locked property to True to cancel the posting of messages to the Test Log. You can implement this in the OnLogError event handler which I was talking about earlier.


     

  • Thanks Tanya, we cannot do that. 

    Sorry for the misunderstanding. I should have wrote: "We want to stop posting image on error for a specific part of the test".



    What I did is the following:

    - First, define a ProjectSuite.Variables.BoolPostImageOnError as a boolean, set to True by default.

    Then:

    function Main()

    {

      test1();

      test2();

      test3();

    }



    function test2()

    {

      ProjectSuite.Variables.BoolPostImageOnError = false; 

      for (i=0; i < 1000; i++)

      {

      CheckFileStatus(i);

      }

     ProjectSuite.Variables.BoolPostImageOnError = true; 

    }



    function GeneralEvents_OnLogError(Sender, LogParams)

    {

    if (ProjectSuite.Variables.BoolPostImageOnError)

      {     

        Log.Picture(Sys.Desktop.Picture(), "Screen shot of the next error message");

      }

    }







    The problem with this workaround is that now every time I have an error, I get 2 lines in the log.



  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Anik,

     


    You can add the Locked property after posting an image via Log.Picture. In this case, only your picture will be posted when BoolPostImageOnError = True.


     

  • Hi Tanya,



    I tried it, but the then the log displays only a message and not an error. :(

    And we can't do log.error in the On_LogError event...
  • chrisb's avatar
    chrisb
    Regular Contributor
    Perhaps I can suggest an alternative solution...

    The log files can be huge even with the minimum of screenshots (I only take one when a test fails) and they can be 100 or 200MB for a small test run. And yes you can zip them but you then have to spend time configuring that feature and then unzip them when you want to view them.

    The approach I took was to write the log file to our network drive (what's a few giga bytes of storage cost these days?)and implement an email notification of the test results instead. I generate all the test metrics I need such as tests passed, failed by using the event handlers to increment values stored in ProjectSuiteVariables. The email notification links to the logfile stored on our network drive should I need to go look at it. As a plus, I find the email notification much easier to read.