Wednesday, November 18, 2009

QTP’S test Object Functions:


Exist: You can enter Exist and/or Wait statements to instruct QuickTest to wait for a window to open or an object to appear. Exist statements return a boolean value indicating whether or not an object currently exists. Wait statements instruct QuickTest to wait a specified amount of time before proceeding to the next step. You can combine these statements within a loop to instruct QuickTest to wait until the object exists before continuing with the test.

Example:

blnDone=Window("Flight Reservation").Dialog("Flights Table").Exist

counter=1

While Not blnDone

Wait (2)

blnDone=Window("FlightReservation").Dialog("FlightsTable").Exist counter=counter+1

If counter=10 then

blnDone=True

End if

Wend

Check Property: Checks whether the specified object property achieves the specified value within the specified timeout.

Syntax: object.CheckProperty (PropertyName, PropertyValue, [TimeOut])

Example:

var_CheckProperty = Browser("HP QuickTest Professional").Page("HP QuickTest Professional").Link("1.2 License Models").CheckProperty("text", "Licence Models")

Return Value

A Boolean value. Returns TRUE if the property achieves the value, and FALSE if the timeout is reached before the property achieves the value.

A TRUE return value reports a Passed step to the test results; a FALSE return value reports a Failed step to the test results.

GetTOProperty: Returns the value of the specified property from the test object description.

Syntax: object.GetTOProperty (Property)

Example : var_GetTOProperty = Browser("HP QuickTest Professional").Page("HP QuickTest Professional").Link("1.2 License Models").GetTOProperty("Innertext")

Return Value: A variant value which will have the inner text of the link “1.2 License Models”

GetROProperty: Returns the current value of the test object property from the object in the application.

Syntax: object.GetROProperty (Property)

Example : var_GetTOProperty = Browser("HP QuickTest Professional").Page("HP QuickTest Professional").Link("1.2 License Models").GetROProperty("Innertext")

Return Value: A variant value which will have the current inner text value of the link “1.2 License Models”

ReportEvent : Reports an event to the test results

Syntax: Reporter.ReportEvent EventStatus, ReportStepName, Details [, Reporter]

Example:

Reporter.ReportEvent 1, "Custom Step", "The user-defined step failed."

or

Reporter.ReportEvent micFail, "Custom Step", "The user-defined step failed."

SystemUtil.Run : You can run any application from a specified location using a SystemUtil.Run statement

Example:SystemUtil.Run"C:\ProgramFiles\InternetExplorer\IEXPLORE.EXE","","C:\Documents and Settings\Administrator","open"

The statement opens the Internet Explorer.

ExecuteFile: This can be used to execute an external VB Script File

Syntax: ExecuteFile FileName

Example : ExecuteFile “C:\sample.vbs”

The above discussed functions can be easily Accessed by step Generator:

1 comment:

  1. First of all. Thanks very much for your useful post.

    I just came across your blog and wanted to drop you a note telling you how impressed I was with the information you have posted here.

    Please let me introduce you some info related to this post and I hope that it is useful for software testing community.

    There is a good Software Testing resource site, Have alook

    http://SoftwareTestingNet.com

    simi

    ReplyDelete

I welcome your comment, will respond and post it at the earliest:)