WORKING WITH QTP

TestEveryThinG

Archive for June, 2010

Compare bitmap file using QTP ( using Mercury.FileCompare object )

Posted by rajivkumarnandvani on June 17, 2010

Hi All,
We can use QTP in-build method for File compare with the help of Mercury.FileCompare.
Here I am going to describe how to use that.

Rem variable to store the location of the expected bitmap file
strstoreBMPfile = “D:\rajivkumarnandvani.bmp”

Rem variable to store the location of the actual bitmap file
strActBMPfile = “D:\rajiv\runtimebmpfile.bmp”

Rem Activate the window

Window(“Flight Reservation”).Activate

Rem Capture the actual bitmap image from the application during run-time
Window(“Flight Reservation”).Static(“Static”).CaptureBitmap strActBMPfile , True

Rem here True will overwrite the file
Rem here we write the function for compare the bitmap file using qtp inbuild method Mercury.FileCompare.
Rem Function FnCompareTwoBMPfiles
Rem Description: this function Compares two bitmap images
Rem input pathExpBMPfile path of Expected bmp file
Rem input pathActBMPfile path of Actual bmp file
Rem return value 1 if both file are same ; 0 if different

Function FnCompareTwoBMPfiles( byval pathExpBMPfile , byval pathActBMPfile)
rem create qtp file system object
Set objMercuryFilecompare = CreateObject(“Mercury.FileCompare”)
rem here we use binary compare
if objMercuryFilecompare.IsEqualBin( pathExpBMPfile , pathActBMPfile , 0,1) Then
rem if match then return 1
FnCompareTwoBMPfiles = 1
else
rem if does not match then return 0
FnCompareTwoBMPfiles = 0
end if
rem discard the object
Set objMercuryFilecompare = nothing
End Function

Rem now we call this function

if FnCompareTwoBMPfiles(strstoreBMPfile ,strActBMPfile) = 1 then
msgbox “ BMP file match”

else
msgbox “BMP file not match”
end IF
Rem same thing we can use for other files also.

Posted in QTP, WINDOWS | Tagged: , , , | 9 Comments »

How can I access HTML tags directly?

Posted by rajivkumarnandvani on June 3, 2010

QuickTest provides direct access to the browser’s Document Object Model
(DOM) through which you can access the HTML tags directly. Access to the
DOM is performed using the .Object notation.
The test below demonstrates how to iterate over all the tags in a page. The
test then outputs the inner-text of the tags (the text contained between the
tags) to the Test Results using the Reporter object.
‘ Use the on error because not all the elements have inner-text.

On Error Resume Next
Set Doc = Browser(“CNN Interactive”).Page(“CNN Interactive”).Object
‘ Loop through all the objects in the page.
For Each Element In Doc.all
TagName = Element.TagName ‘ Get the tag name.
InnerText = Element.innerText ‘ Get the inner text.
‘ Write the information to the test results.
Reporter.ReportEvent 0, TagName, InnerText
Next

Posted in QTP, WEB | 1 Comment »

 
%d bloggers like this: