How to take a screenshot using VBScript in TestComplete?

I am using TestComplete. I need to take a screenshot and put it in a specific folder. How to do it with VBScript?

+5
source share
2 answers

To take a screenshot of the desktop, use the method Sys.Desktop.Picture. To save the resulting image to a file, use the method SaveToFile:

Sys.Desktop.Picture.SaveToFile "E:\screenshot.png"

Alternatively, you can enable Test Visualizer to automatically capture screenshots for your test activities.

+2
source
Function CaptureScreenShot(ScreenshotPath )  
  'Generate Name of the Image 
  strimgFileName="Img\Img" & Day(Date)& Month(Date) & Year(Date) & Hour(Now) & Minute(Now) & Second(Now) &".jpg"  
  strImgFile= ScreenshotPath & strimgFileName   
  'Capture failure Screen shot 
  Set objPic = Sys.Desktop.Picture()  
  'Save captured Screen shot 
  ExecutionStatus = objPic.SaveToFile(strImgFile)  
  'Return Captured image name
  CaptureScreenShot=".\" & strimgFileName  
End Function    
0
source

All Articles