I'm using TestComplete. I need to capture a screenshot and place it in a particular folder. How to do this using VBScript?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To capture a desktop screenshot, use the Sys.Desktop.Picture
method. To save the resulting image to a file, use its SaveToFile
method:
Sys.Desktop.Picture.SaveToFile "E:\screenshot.png"
Alternatively, you can turn on the Test Visualizer to automatically capture screenshots for your test actions.
回答2:
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