如何在TestComplete中使用VBScript捕获屏幕截图?

时间:2013-03-05 06:38:22

标签: vbscript screenshot testcomplete

我正在使用TestComplete。我需要捕获屏幕截图并将其放在特定文件夹中。如何使用VBScript做到这一点?

2 个答案:

答案 0 :(得分:2)

要捕获桌面屏幕截图,请使用Sys.Desktop.Picture方法。要将生成的图像保存到文件,请使用其SaveToFile方法:

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

或者,您可以打开Test Visualizer自动捕获测试操作的屏幕截图。

答案 1 :(得分:0)

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