Forum Discussion

kcarr86's avatar
Occasional Contributor
2 years ago

Save a Screenshot of Application window

Hello, I am fairly new to TestComplete and have been exclusively working with Keyword Tests. I'm trying to take a screenshot of an application window and then save that file to a folder on my compute...
  • Kitt's avatar
    2 years ago

    You can use this to capture the entire screen and save it to where your project logs are saved (ProjectSuite/Project/Log/Current_DateTime_Folder/Picture1.png):


    Log.Picture(Sys.Desktop.Picture(), "Image of the error");


    and if you need to move the file to another directory you can do the following:


    aqFileSystem.MoveFile(Log.Picture(Sys.Desktop.Picture(), "Image moved to C:\temp"), "C:\\temp\\"); 


    NOTE: this will automatically remove the image from the TC posted log, so it won't display in the TC app, but will instead be moved to the directory you specify (in this case C:\temp)

     OR better yet, copy the file and you get it in both folders:


    aqFileSystem.CopyFile(Log.Picture(Sys.Desktop.Picture(), "Image copied to C:\temp"), "C:\\temp\\"); 




  • Marsha_R's avatar
    2 years ago

    I think it would be easier for you to use a Data Driven Loop. This will give you a much easier way to access your Excel information.

    You can use a string variable to build the file name that you want from the Excel data and then use that variable in your path.

    mypathstring = myexceldata + ".jpg"

    Using intermediate steps like this seems like extra work sometimes but it's worth a little time here in case you need to troubleshoot when things aren't working.