QTP provides the object called "SystemMonitor" which can be used to get Memory and Processor usage.
'To find the Memory usage of an application, use below:
SystemMonitor.GetValue("Application name without extension", "counter name")
Ex: msgbox SystemMonitor.GetValue("QTPro","Memory Usage (in MB)")
'To find the Processor usage of an application, use below:
Ex: msgbox SystemMonitor.GetValue("javaw","% Processor Time")
Saturday, February 25, 2012
Tuesday, February 21, 2012
Right click on a weblink using QTP
'The below scripts selects the second pop up item after right clicking on the weblink.
'Open the Yahoo website in IE and execute the script.
'Opens the images webpage(open in new tab) in a new tab
Setting.WebPackage("ReplayType") = 2
'This statement makes the replay type to Mouse from event. Without this configuration the script may or may not work.
Set link=browser("Yahoo!").Page("Yahoo!").Link("Images")
link.highlight
index=2
Set obj = CreateObject("Mercury.DeviceReplay")
Set WshShell = CreateObject("WScript.Shell")
'Get the absolute coordinates of the object
absx = link.GetROProperty("abs_x")
absy = link.GetROProperty("abs_y")
'Right click on the Object
obj.MouseClick absx+5, absy+5, 2 'Here 2 is for right click
'Optional wait statement
wait 2
'Clicking number of downs
For i = 1 To index
WshShell.sendkeys "{DOWN}"
Next
WshShell.sendkeys "{ENTER}"
Setting.WebPackage("ReplayType") = 1
Set WshSEll = nothing
Set obj = nothing
'Open the Yahoo website in IE and execute the script.
'Opens the images webpage(open in new tab) in a new tab
Setting.WebPackage("ReplayType") = 2
'This statement makes the replay type to Mouse from event. Without this configuration the script may or may not work.
Set link=browser("Yahoo!").Page("Yahoo!").Link("Images")
link.highlight
index=2
Set obj = CreateObject("Mercury.DeviceReplay")
Set WshShell = CreateObject("WScript.Shell")
'Get the absolute coordinates of the object
absx = link.GetROProperty("abs_x")
absy = link.GetROProperty("abs_y")
'Right click on the Object
obj.MouseClick absx+5, absy+5, 2 'Here 2 is for right click
'Optional wait statement
wait 2
'Clicking number of downs
For i = 1 To index
WshShell.sendkeys "{DOWN}"
Next
WshShell.sendkeys "{ENTER}"
Setting.WebPackage("ReplayType") = 1
Set WshSEll = nothing
Set obj = nothing
Subscribe to:
Posts (Atom)