Mercury Timer Object
An internal timer object that measures the passage of time in milliseconds.
Important Information
The MercuryTimer object is an internal timer item of the MercuryTimers collection object.
Associated Methods
Associated Property
How to compare two images using QTP
We know by using Bitmap checkpoint, we can compare two images.
But is there a other way we can compare?
Yes, we can use "IsEqualBin" method from Mercury.FileCompare
sImgPath1="C:\Users\user\Downloads\SAI 01461_exposure.JPG"
'sImgPath2="C:\Users\user\Downloads\SAI 01462_exposure.JPG"
sImgPath2="C:\Users\user\Downloads\SAI 0175_exposure.JPG"
Set obj=createobject("Mercury.FileCompare")
retVal=obj.IsEqualBin(sImgPath1,sImgPath2,1,1)
print retVal
Set obj=nothing
The retVal=1 if both the images are same
else retVal=0
But is there a other way we can compare?
Yes, we can use "IsEqualBin" method from Mercury.FileCompare
sImgPath1="C:\Users\user\Downloads\SAI 01461_exposure.JPG"
'sImgPath2="C:\Users\user\Downloads\SAI 01462_exposure.JPG"
sImgPath2="C:\Users\user\Downloads\SAI 0175_exposure.JPG"
Set obj=createobject("Mercury.FileCompare")
retVal=obj.IsEqualBin(sImgPath1,sImgPath2,1,1)
print retVal
Set obj=nothing
The retVal=1 if both the images are same
else retVal=0
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
No comments:
Post a Comment