You are on page 1of 2

- KnowledgeInbox (By Tarun Lalwani) - http://knowledgeinbox.

com -

Capturing values from an Application objects


Posted By Tarun Lalwani On January 8, 2009 @ 4:01 am In Uncategorized | Comments
Disabled

Checkpoints and validations can be done by capturing actual values from an object in the
Application and then comparing that value with some predefined value. QTP provides various
methods for capturing values from an Application object. We will discuss all of these methods
in detail.

Checkpoints

Checkpoints can be used for validating an Actual value against Expected value. A Checkpoints
can capture and compare multiple values. One problem with capturing values using
Checkpoints is that the capture values are not visible at run-time, they can only be viewed in
the test results summary. Thought it is possible to capture the final result of the Checkpoint
and see if it passed or failed. The code shown below demonstrated how to capture the result
of a checkpont

Dim bPassed
bPassed = Browser("X").Page("X").WebEdit("X").Check ( CheckPoint("Y") )

If bPassed Then
Msbox "Passed"
End if

Note that we have used parenthesis before and after ‘CheckPoint(”Y”)’, this is required when
we want to capture the value returned from Check method. If the return value is not to be
capture and only the Checkpoint needs to executed we can use
‘Browser(”X”).Page(”X”).WebEdit(”X”).Check CheckPoint(”Y”)’

Output Value

Output Value is used to extract property value from object and store it in DataTable or
Environment variable. Consider a Checkpoint “txtTest” which extracts the value of “html tag”
and “value” of a text box into the Global DataTable. Example of an Output Value is shown
below

Browser(”X”).Page(”X”).WebEdit(”txtTest”).Output CheckPoint(”txtTest”)

Running the above code will output value of the “html tag” and “value” property into the
DataTable.

GetROProperty

GetROProperty method can be used to fetch property values for an object. The “txtTest”
Checkpoint we used earlier can be simulated using GetROProperty as shown in the code below

DataTable("txtTest_html_tag_out", dtGlobalSheet) =
Browser("X").Page("X").WebEdit("txtTest").GetROProperty("html tag")
DataTable("txtTest_value_out", dtGlobalSheet) =
Browser("X").Page("X").WebEdit("txtTest").GetROProperty("value")

Using GetROProperty makes things more flexible when compared with Output Values. Output
Value can only fetch the values into DataTable or Environment, on the other we can use
GetROProperty to fetch data in any variable or data storage holder.

Which method to use?

When it comes to choosing the best method for capturing values, i vote for GetROProperty for
the following reasons

• Checkpoints can’t be used to capture values at run-time


• Output Value can’t be modified at run-time i.e. we can’t add or remove a property
from a Ouput Value
• Output Value limits fetching the data into DataTable or Environment Variables only
• Output Value gets stored within the Object Repository and is not visible in QTP 9.2 or
lower
• Output Value can’t be directly added to a Shared Object Repository
• Output Value can’t be created dynamically at run-time

Article printed from KnowledgeInbox (By Tarun Lalwani): http://knowledgeinbox.com

URL to article: http://knowledgeinbox.com/articles/qtp/checkpoints/capturing-


values-from-an-application-objects/

Click here to print.

Copyright © 2008 KnowledgeInbox (By Tarun Lalwani). All rights reserved.

You might also like