Today, I will talk about the different ways to validate picture:
1) Using QTP Bitmap checkpoint:
Using QTP Bitmap CheckPoint, picture can be verified against the previously recorded picture.
Syntax for checkpoint:
res_val=Window(“Microsoft PowerPoint”).Window(“Slide”).WinObject(“Slide”).Check (CheckPoint(“Slide_3”))
where res_val = result value returned by the checkpoint. It is true in case if current image matches with previously recorded image and false otherwise.
2) Using GetVisibleText method:
You can use GetVisibleText method to extract text from the picture (and compare text in the picture). This is generally used when QTP is unable to identify the particular control.
Syntax for GetVisibleText:
where strText = text visible on the object specified in the object hierarchy
3) Using Mercury.FileCompare utility:
This method is undocumented. This method is very accurate in terms of comparing two pre-captured images
Before using this method, we need to capture two images to be compared.
We can do that using QTP’s inbuilt CaptureBitMap method
where filePath1 = path where we want our image file to get saved
override_Existing = optional parameter that specifies whether the file can be overwritten if file with the same name exits on the location.
It is True if we want existing file to be overwritten and False otherwise. It is False by default if we don’t specify any parameter
Set oCompareUtil = CreateObject(“Mercury.FileCompare”)
res_val = oCompareUtil.IsEqualBin(filePath1,filePath2, 0,1)
Set oCompareUtil = Nothing
where filePath1 and filePath2 are the paths of the files to be compared
res_val = value returned by this method. It is 1 if both the files are equal and 0 otherwise.
Categories: Awesum Stuff