Wednesday, 16 January 2013

Capturing Screenshot and Saving with Timestamp

Capturing Screenshot and Saving with Timestamp

  Dim ScreenName
  On Error Resume Next
  ScreenName = ""

  CurrentTime = "_Test_Case"&"_"& Day(Now)&"_"& Month(Now)&"_"& Year(Now)&"_"& Hour(Now)&"_"& Minute(Now)&"_"& Second(Now)
  'Set the screen shot name
  ScreenShotName = "Screenshot" &  CurrentTime & ".png"
  'Final screenshot location
  ScreenName ="C:\Documents and Settings\Pankaj Kumar Ocmpf\Desktop\New Folder (2)"&"\"&ScreenShotName
  ' just capture
  Desktop.CaptureBitmap ScreenName,True 
******************************************************************
Public Function ScreenCapture()
Dim vNow, vFile
vNow = Replace(Replace(Replace(now(),":","_"),"/","_")," ","_")
vfile ="\\Cd102162\SOS_Optus\ "&vNow&".png"
'Capture Browser Scrren shot
Browser("micclass:=Browser").FullScreen
Browser("micclass:=Browser").CaptureBitmap vFile, True
' Add the Captured Screen shot to the Results file
Reporter.ReportEvent micDone,"Screen Shot","&lt;<img src='" &vFile& "'>&gt;"
End Function

7 comments:

  1. Good afternoon

    Do you know how I can get the image in .jpg or .jpeg format, I ask this because .bmp is too big, and I neef to take a lot of screenshots

    ReplyDelete
  2. I forgot to thank you, thanks for your help :D

    ReplyDelete
  3. thanks alot

    regards,
    Neha
    https://speakingdots.com

    ReplyDelete
  4. What's the use of following sentence:
    "\\Cd102162\SOS_Optus\ "

    ReplyDelete
  5. Is there any way to capture screen shot in hybrid framework?

    ReplyDelete
  6. Screenshot = "D:\"&Hour(Now)&".png"
    Browser("Login").Page("Login").CaptureBitmap Screenshot.True
    This above code is working fine but when i use Now() or Time() functions in the place of Hour(Now) it's not working.
    Screenshot = "D:\"&Now()&".png"
    Browser("Login").Page("Login").CaptureBitmap Screenshot.True

    ReplyDelete