Awesum Stuff

How to extract text from picture/images using QTP?

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:
strText=Window(“Microsoft PowerPoint”).Window(“Slide”).WinObject(“Slide”).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

Syntax:

For CaptureBitMap:
Desktop.CaptureBitmap filePath1,override_Existing

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

For Mercury.FileCompare:
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.

Advertisements

2 replies »

  1. Hello! This is my first visit to your blog! We are a collection
    of volunteers and starting a new initiative in a community in the same niche.
    Your blog provided us beneficial information to
    work on. You have done a extraordinary job!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s