Forum Discussion

joaobc's avatar
joaobc
Occasional Contributor
5 years ago

Attach printscreen to Log.Checkpoint

The only way I can post a printscreen of the entire screen is this way:
Log.Picture(Sys.Desktop.Picture(), "OK Message");

 

Reading the documentation of Checkpoint method (https://support.smartbear.com/testcomplete/docs/reference/project-objects/test-log/log/checkpoint.html), I try this:

Log.Checkpoint("OK Message",Sys.Desktop.Picture()), but nothing show in the Tab Picture

what is the correct way to take a screenshot of the screen to put in the Log.Checkpoint () method?



  • joaobc's avatar
    joaobc
    5 years ago

    I already try this, but get the error: Unexpected Token ,

     

    I confused, I thought the method would be able to detect the type of the object, because besides the one you commented on, I tried to pass blank strings and get runtime error. I didn't notice the other default values ​​on the right side of the table.

     

    Log.Checkpoint("OK Message","","","",Sys.Desktop.Picture()) -- get JavaScript runtime error.

     

    I solved using null, and only the priority need the parameter: pmNormal or any integer and the picture object or method which return a picture object.


    Log.Checkpoint("OK Message",null,pmNormal,null,Aliases.myApp.Picture())

    Log.Checkpoint(null,null,pmNormal,null,Aliases.myApp.Picture())

     

     

  • Try something like   Log.Checkpoint("OK Message",,,Sys.Desktop.Picture())

     

    The picture needs to be the number 5 parameter

    • joaobc's avatar
      joaobc
      Occasional Contributor

      I already try this, but get the error: Unexpected Token ,

       

      I confused, I thought the method would be able to detect the type of the object, because besides the one you commented on, I tried to pass blank strings and get runtime error. I didn't notice the other default values ​​on the right side of the table.

       

      Log.Checkpoint("OK Message","","","",Sys.Desktop.Picture()) -- get JavaScript runtime error.

       

      I solved using null, and only the priority need the parameter: pmNormal or any integer and the picture object or method which return a picture object.


      Log.Checkpoint("OK Message",null,pmNormal,null,Aliases.myApp.Picture())

      Log.Checkpoint(null,null,pmNormal,null,Aliases.myApp.Picture())

       

       

  • just out of curiosity, would you mind explaining the use case of capturing the entire desktop as a picture within your logs?

    • joaobc's avatar
      joaobc
      Occasional Contributor

      For those who copy the code and paste it in the testcomplete do not need to change the last parameter to Aliases.<application name>.Picture()

      • Marsha_R's avatar
        Marsha_R
        Moderator

        joaobc Glad you found your answer!

         

        It's been my experience in the languages I've used that if there is a list of parameters, then you have to enter something for each of them up to and including the one you need.  After that you can leave them off.  Detecting the type of object rather than just looking at the position would be more complicated and in some cases useless (say if all parameters are strings, which string did you just find?).