Forum Discussion

Hardy's avatar
Hardy
Occasional Contributor
7 years ago
Solved

how to specify the screenshot's name?

  1. Used "Post Screenshot" to capture a screenshot
  2. After executed the case, it will generate the log and screenshot, we notice that the screenshot's name default as "Picture 1/2/3", can we specify the screenshot name like this: Case no.1 - Customer, Case no.2 - Contract. Pls refer to the attached screenshot for more detail.
  • Not using the Post Screenshot method.  This is not intended to capture a screenshot and name it as a file, it is simply an operation to put a screenshot into the TestComplete test log.  By default, each picture in the log is named, simply, Picture1, 2, 3, etc.

     

    In order to save the image with a particular name, you would call the "Picture" method of the onscreen object desired and then call the SaveToFile method from that... something like

     

    Aliases.MyApp.MyObject.Picture().SaveToFile('MyPictureFile.JPG')

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Not using the Post Screenshot method.  This is not intended to capture a screenshot and name it as a file, it is simply an operation to put a screenshot into the TestComplete test log.  By default, each picture in the log is named, simply, Picture1, 2, 3, etc.

     

    In order to save the image with a particular name, you would call the "Picture" method of the onscreen object desired and then call the SaveToFile method from that... something like

     

    Aliases.MyApp.MyObject.Picture().SaveToFile('MyPictureFile.JPG')
    • Hardy's avatar
      Hardy
      Occasional Contributor
      Aliases.MyApp.MyObject.Picture().SaveToFile('MyPictureFile.JPG') This method will name the screenshot and save to the specify path. So i have another question, can save the rename screenshot to the default log path instead of the specify path?
    • Hardy's avatar
      Hardy
      Occasional Contributor
      I have resolved my question, thanks a lot. I use the Log.Patch method to get the path, and save the screenshot to this path. def test(): sPath = Log.Path Aliases.MyApp.MyObject.Picture().SaveToFile(sPath + "Case1_Customer.JPG")