Screenshots on VM with QTP




I am sure a lot of you have noticed that taking screenshots on a VM will result in a blank screen :)

The solution is that the machine should not be locked while running your scripts , similar to a solution provided in my earlier posts.If you missed that out here is the code:

Content of vbs File (keykaker):

' Keyboard activity faker
Set shell = WScript.CreateObject("WScript.Shell")
Set args = WScript.Arguments
interval = 180
key = "+"
output = True

' If running under WScript were not in a console so disable any output
If InStr(LCase(WScript.FullName), "wscript") > 0 Then output = False
' Handle the arguments
If args.Count > 0 Then
temp = args.Item(0)
If Not IsNumeric(temp) Then
WScript.Echo "Interval must be numeric"
WScript.Quit 1
ElseIf temp < 1 Then
WScript.Echo "Interval must be greater or equal to 1"
WScript.Quit 1
Else
interval = temp
End If
End If
If args.Count = 2 Then
key = args.Item(1)
End If
' Output some blurb so the user knows what's happening
key_desc = key
If key = "+" Then key_desc = "Shift Key"
If key = "^" Then key_desc = "Ctrl Key"
If key = "%" Then key_desc = "Alt Key"
If output Then WScript.Echo "Key press faker started: Interval = "&interval&" seconds, Key = '"&key_desc&"'"
' Main loop, easy init?
While True
If output Then WScript.Echo "Faking keypress at " & Time
shell.SendKeys key
WScript.Sleep interval * 1000
Wend

TIP: As per the suggestion in the below link, instead of directly closing the remote session, executing the command “tscon.exe 0 /dest:console” on the remote machine to close the session, ensures that the remote console is still active, which will allow QTP to capture screenshot.

http://www.sqaforums.com/showflat.php?Number=701178

Comments

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?