Adding Properties to a Test Object Description

You can add to the list of properties that QuickTest uses to identify an object. For each object class, QuickTest has a default property set that it uses for the object description for a particular object. You can use the Add Properties dialog box to change the properties that are included in the object description. You can do this for objects in the local object repository using the Object Repository window or Object Properties dialog box, and for objects in the shared object repository using the Object Repository Manager.

Note: You can also add any valid test object property to a test object description, even if it does not appear in the Add Properties dialog box..

Adding to the list of properties is useful when you want to create and run components on an object that changes dynamically. An object may change dynamically if it is frequently updated, or if its property values are set using dynamic content (for example, from a database).

You can also change the properties that identify an object if you want to reference objects using properties that were not automatically learned while recording. For example, suppose you are testing a Web site that contains an archive of newsletters. The archive page includes a hypertext link to the current newsletter and additional hypertext links to all past newsletters. The text in the first hypertext link on the page changes as the current newsletter changes, but it always links to a page called current.html. Suppose you want to create a step in your component in which you always click the first hypertext link in your archive page. Since the news is always changing, the text in the hypertext link keeps changing. You need to modify how QuickTest identifies this hypertext link so that it can continue to find it.

The default properties for a Link object (hypertext link) are text and HTML tag. The text property is the text inside the link. The HTML tag property is always A, which indicates a link.

You can modify the default properties for a hypertext link for the object that was recorded so that you can identify it by its destination page, rather than by the text in the link. You can use the "href" property to check the destination page instead of using the "text" property to check the link by the text in the link.

Tip: You can use the Object Spy at any time to view run-time or test object properties and values of the objects in the application you are testing. You open the Object Spy by choosing Tools > Object Spy or clicking the Object Spy toolbar button

Note: You can also modify the set of properties that QuickTest learns when it records objects from a particular object class using the Object Identification dialog box. Such a change generally affects only objects that you learn or record after you make the change. You can also apply the changes you make in the Object Identification dialog box to the descriptions of all objects in an existing component using the Update Run Mode option.

To add properties to a test object description:

  1. In the object repository tree, select the test object whose description you want to modify.
  2. In the Test object details area, click the Add description properties button .

Tip: For an object in the local object repository, you can also select the required test object and choose Edit > Step Properties > Object Properties, click the Add description properties button , and then perform the following steps in the Add Properties dialog box.

The Add Properties dialog box opens listing the properties that can be used to identify the object (properties that are not already part of the test object description). The value for each property is displayed in the Value column.

Notes: Values for all properties are displayed only if the application that contains the object is currently open. If the application is closed, only values for properties that were part of the object description when the object was learned are shown.

You can resize the Add Properties dialog box to enable you to view long property values.

You can click the Define new property button to add valid test object properties to this properties list..

  1. Select one or more properties to add to the test object description and click OK. You can also double-click a property to add it to the test object description. You can type the first letters of a property to highlight the first property in the list that matches the pattern.

Tip: After you add a new property to the object description, you can modify its value

QuickTest Automation Object Model

Essentially all configuration and run functionality provided via the QuickTest interface is in some way represented in the QuickTest automation object model via objects, methods, and properties. Although a one-on-one comparison cannot always be made, most dialog boxes in QuickTest have a corresponding automation object, most options in dialog boxes can be set and/or retrieved using the corresponding object property, and most menu commands and other operations have corresponding automation methods.

You can use the objects, methods, and properties exposed by the QuickTest automation object model, along with standard programming elements such as loops and conditional statements to design your script.

Automation scripts are especially useful for performing the same tasks multiple times or on multiple tests or components, or quickly configuring QuickTest according to your needs for a particular environment or application.

For example, you can create and run an automation script from Microsoft Visual Basic that loads the required add-ins for a test or component, starts QuickTest in visible mode, opens the test or component, configures settings that correspond to those in the Options, Test or Business Component Settings, and Record and Run Settings dialog boxes, runs the test or component, and saves the test or component.

You can then add a simple loop to your script so that your single script can perform the operations described above for multiple tests or components.

You can also create an initialization script that opens QuickTest with specific configuration settings. You can then instruct all of your testers to open QuickTest using this automation script to ensure that all of your testers are always working with the same configuration.

What is Automation

Automation is a Microsoft technology that makes it possible to access software objects inside one application from other applications. These objects can be easily created and manipulated using a scripting or programming language such as VBScript or VC++. Automation enables you to control the functionality of an application programmatically.

An object model is a structural representation of software objects (classes) that comprise the implementation of a system or application. An object model defines a set of classes and interfaces, together with their properties, methods and events, and their relationships.

Connecting to a database in QTP

Use the below code for connecting a database from QTP.Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=;PWD="
objRecordset.CursorLocation = adUseClient
objRecordset.CursorType = adopenstatic
objRecordset.LockType = adlockoptimistic
ObjRecordset.Source="select field1,field2 from testTable"
ObjRecordset.ActiveConnection=ObjConnection
ObjRecordset.Open 'This will execute your Query
If ObjRecordset.recordcount>0 then
Field1 = ObjRecordset("Field1").Value
Field2 = ObjRecordset("Field2").Value
End if