Simple QTP Script/code example of how to query an access database.

This is my tutorial on how to build a query that you can use in VBScript to extract information from a database.
The level of difficulty for this tutorial is beginner to intermediate.

You need to know basic VBScript syntax and need to have a copy of MS Access.

Code Starts from here:

dim objDB
dim objRS
dim intCounter

' create a database and recordset objects
Set objDB = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.RecordSet")

' configure the connection
objDB.Provider="Microsoft.Jet.OLEDB.4.0"
objDB.Open
"c:\MyTestDatabase.mdb"

' count the number of records in the employee table
objRS.Open "SELECT COUNT(*) from Employee" , objDB

Msgbox "There are " & objRS.Fields(0).Value & " records in the employee table."

' destroy the objects
Set objDB = Nothing
Set objRS = Nothing

Array Basics

Some basic info about creating and using arrays.

' The easiest way create an array is to simply declare it as follows
Dim strCustomers()

' Another method is to define a variable and then set it as an array afterwards
Dim strStaff
strStaff = Array("Alan","Brian","Chris")

' Yet another way is to use the split command to create and populate the array
Dim strProductArray
strProductArray = "Keyboards,Laptops,Monitors"
strProductArray = Split(strProductArray, ",")

' To itterate through the contents of an array you can use the For Each loop
Dim strItem
For Each strItem In strProductArray
MsgBox strItem
Next

' This will also itterate through the loop
Dim intCount
For intCount = LBound(strProductArray) To UBound(strProductArray)
Msgbox strProductArray(intCount)
Next

' This will itterate through the array backwards
For intCount = UBound(strProductArray) To LBound(strProductArray) Step -1
Msgbox strProductArray(intCount)
Next

' To add extra data to an array use Redim Preserve
Redim Preserve strProductArray(3)
strProductArray(3) = "Mice"

' To store the contents of an array into one string, use Join
Msgbox Join(strProductArray, ",")

' To delete the contents of an array, use the Erase command
Erase strProductArray

Object Identification: -

QTP’s object identification concept is based on 4 types of properties and an ordinal identifier.

Types of properties:

• Mandatory properties
• Assistive properties
• Base Filter properties
• Optional Filter properties
A test engineer can specify list of mandatory properties, assistive properties, base filter properties, optional filter properties and ordinal identifier.

QTP will learn the information in the following way: -
First of all QTP will learn all the specified mandatory properties and then think whether these properties are sufficient to identify the object uniquely. If it feels sufficient it will stop learning. Otherwise it will learn the 1st assistive property. Then once again think whether all the properties are sufficient for identifying the object uniquely. If at all it feels sufficient it will stop learning otherwise it will learn the 2nd assistive property and then think again whether all these properties are sufficient for identifying the object uniquely. This process continues till the QTP get satisfied or up to the end of the assistive properties list.

If still QTP feels not satisfied then finally it will learn the ordinal identifier. All the properties learnt during this process will be stored in the object repository.
If at all the smart identification option is selected then the QTP will learn the base filter properties, optional filter properties along with the mandatory properties and stores the base filter properties and optional filter properties separately and secretly and then continues with the same procedure as above.

QTP uses the learnt information in the following way to identify the object: -

First of all QTP will use all the properties present in the object repository except ordinal identifier and tries to identify the object. If it fails then it will enter into the smart brain by forgetting about all the properties present in the object repository and then considers all the base filter properties and try to match with all the objects in the AUT. The objects that are matched with all these properties are formed as a list and if the list is containing only one object then that is the object. Otherwise it will take the support of first optional filter property and try to match with the objects in the list. Whatever the objects that are matched with this property will be formed as a new list and if the list contains only one object then that is the object. Otherwise it will take the support of 2nd optional filter property and try to match with all the properties in the new list. This procedure continues till the list contains one object or up to the end of the optional filter properties list.

If still the QTP is unable to identify the object then it will go to the object repository and if at all the ordinal identifier is available in the object repository then it will identify the object roughly using the ordinal identifier.
Smart Identification: - Smart Identification is a mechanism provided by QTP, which is used for identifying the objects even though some properties are dynamically changed.

Ordinal Identifiers: - There are 3 types of ordinal identifiers.
1. Location
2. Index
3. Creation Time

1. Location: If at all the Location is selected as an ordinal identifier then the QTP will generate the sequence of numbers from 0,1,2,… based on the sequence of the objects located in the application.
2. Index: If at all the index is selected as an ordinal identifier then the QTP will generate the sequence of numbers from 0,1,2,… based on the sequence of the programs of the corresponding objects.
3. Creation time: If at all the creation time is selected as an ordinal identifier then the QTP will generate the sequence of numbers from 0,1,2,... based on the loading time of a web page.

1. What are the Features & Benefits of Quick Test Pro(QTP)..?

1. Key word driven testing
2. Suitable for both client server and web based application
3. VB script as the script language
4. Better error handling mechanism
5. Excellent data driven testing features

2. How to handle the exceptions using recovery scenario manager in QTP?

You can instruct QTP to recover unexpected events or errors that occurred in your testing environment during test run. Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has three steps
1. Triggered Events
2. Recovery steps
3. Post Recovery Test-Run

3. How to handle the exceptions using recovery scenario manager in QTP?

You can instruct QTP to recover unexpected events or errors that occurred in your testing environment during test run. Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has three steps:
1. Triggered Events
2. Recovery steps
3. Post Recovery Test-Run

3. What is the use of Text output value in QTP?

Output values enable to view the values that the application talks during run time. When parameterized, the values change for every iteration. Thus by creating output values, we can capture the values that the application takes for each run and output them to the data table.

4. How to use the Object spy in QTP?

There are two ways to Spy the objects in QTP
1) Thru file toolbar
---In the File Tool Bar click on the last toolbar button (an icon showing a person with hat).
2) Thru Object repository Dialog
---In Object repository dialog click on the button “object spy...”
In the Object spy Dialog click on the button showing hand symbol.
The pointer now changes in to a hand symbol and we have to point out the object to spy the state of the object
If at all the object is not visible or window is minimized then Hold the Ctrl button and activate the required window to and release the Ctrl button.

5. What is the file extension of the code file & object repository file in QTP?

File extension of
-- Per test object rep: - filename.mtr
-- Shared Object rep: - filename.tsr
-- Codes file extension id: - script.mts

6. Explain the concept of object repository & how QTP recognizes objects?

Object Repository: displays a tree of all objects in the current component or in the current action or entire test (depending on the object repository mode you selected).
We can view or modify the test object description of any test object in the repository or to add new objects to the repository.
Quick test learns the default property values and determines in which test object class it fits. If it is not enough it adds assistive properties, one by one to the description until it has compiled the unique description. If no assistive properties are available, then it adds a special Ordinal identifier such as objects location on the page or in the source code.

7. What are the properties you would use for identifying a browser & page when using descriptive programming?

"Name" would be another property apart from "title" that we can use.
OR
We can also use the property "micClass".
Ex: Browser("micClass:=browser").page("micClass:=page")....

8. What are the different scripting languages you could use when working with QTP?

Visual Basic (VB), XML, JavaScript, Java, HTML

9 Give example where you have used a COM interface in your QTP project?

COM interface appears in the scenario of front end and back end. for eg:if you r using oracle as back end and front end as VB or any language then for better compatibility we will go for an interface. of which COM will be one among those interfaces. Create object creates handle to the instance of the specified object so that we program can use the methods on the specified object. It is used for implementing Automation(as defined by Microsoft).

10. Few basic questions on commonly used Excel VBA functions.

Common functions are:
Coloring the cell
Auto fit cell
Setting navigation from link in one cell to other
Saving

11. Explain the keyword create object with an example.

Creates and returns a reference to an Automation object
Syntax: CreateObject(servername.typename [, location])
Arguments
SERVERNAME: Required. The name of the application providing the object
TYPENAME: Required. The type or class of the object to create
LOCATION: Optional. The name of the network server where the object is to be created

12. Explain in brief about the QTP Automation Object Model.

Essentially all configuration and run functionality provided via the QTP interface is in some way represented in the QTP automation object model via objects, methods, and properties. Although a one-on-one comparison cannot always be made, most dialog boxes in QTP 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 QTP automation object model, along with standard programming elements such as loops and conditional statements to design your program.

13. How to handle dynamic objects in QTP?

QTP has a unique feature called Smart Object Identification/recognition. QTP generally identifies an object by matching its test object and run time object properties. QTP may fail to recognize the dynamic objects whose properties change during run time. Hence it has an option of enabling Smart Identification, wherein it can identify the objects even if their properties changes during run time.
Check this out-
If QuickTest is unable to find any object that matches the recorded object description, or if it finds more than one object that fits the description, then QuickTest ignores the recorded description, and uses the Smart Identification mechanism to try to identify the object.
While the Smart Identification mechanism is more complex, it is more flexible, and thus, if configured logically, a Smart Identification definition can probably help QuickTest identify an object, if it is present, even when the recorded description fails.
The Smart Identification mechanism uses two types of properties:
Base filter properties—the most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a Web link's tag was changed from to any other value; you could no longer call it the same object. Optional filter properties—other properties that can help identify objects of a particular class as they are unlikely to change on a regular basis, but which can be ignored if they are no longer applicable.

14. What is a Run-Time Data Table? Where can I find and view this table?

In QTP, there is data table used, which is used at runtime.
-In QTP, select the option View->Data table.
-This is basically an excel file, which is stored in the folder of the test created, its name is Default.xls by default.

15. How does Parameterization and Data-Driving relate to each other in QTP?

To data drive we have to parameterize i.e. we have to make the constant value as parameter, so that in each iteration (cycle) it takes a value that is supplied in run-time data table. Through parameterization only we can drive a transaction (action) with different sets of data. You know running the script with the same set of data several times is not suggestible, & it's also of no use.

16. What is the difference between Call to Action and Copy Action.?

Call to Action: The changes made in Call to Action, will be reflected in the original action (from where the script is called).But where as in Copy Action, the changes made in the script, will not affect the original script (Action)

17. Discuss QTP Environment.

QuickTest Pro environment using the graphical interface and Active Screen technologies - A testing process for creating test scripts, relating manual test requirements to automated verification features - Data driving to use several sets of data using one test script.

18. Explain the concept of how QTP identifies object.

During recording QTP looks at the object and stores it as test object. For each test object QT learns a set of default properties called mandatory properties, and look at the rest of the objects to check whether this properties are enough to uniquely identify the object. During test run, QT searches for the run time objects that match with the test object it learned while recording.

19. Differentiate the two Object Repository Types of QTP.

Object repository is used to store all the objects in the application being tested. 2 types of object repository per action and shared. In shared repository only one centralized repository for all the tests, where as in per action for each test a separate per action repository is created.

20. What the differences are and best practical application of each.

Per Action: For Each Action, one Object Repository is created.
Shared: One Object Repository is used by entire application

21. Explain what the difference between Shared Repository and Per_Action Repository

Shared Repository: Entire application uses one Object Repository, that similar to Global GUI Map file in WinRunner
Per Action: For each Action, one Object Repository is created, like GUI map file per test in WinRunner

22. Have you ever written a compiled module? If yes tell me about some of the functions that you wrote.

I used the functions for capturing the dynamic data during runtime. Function used for Capturing Desktop, browser and pages.

23. What projects have you used WinRunner on? Tell me about some of the challenges that arose and how you handled them.

PBS: WR fails to identify the object in GUI. If there is a non standard window object cannot recognize it, we use GUI SPY for that to handle such situation.

24. Can you do more than just capture and playback?

I have done dynamically capturing the objects during runtime in which no recording, no playback and no use of repository is done AT ALL.
-It was done by the windows scripting using the DOM (Document Object Model) of the windows.

25. How to do the scripting. Are there any inbuilt functions in QTP as in QTP-S.? What is the difference between them? How to handle script issues?

Yes, there's an in-built functionality called "Step Generator" in Insert->Step->Step Generator -F7, which will generate the scripts as u enter the appropriate steps.

26. What is the difference between check point and output value.

I would like to add some stuff to Kalpana's comments.
It is as follows:-
An outPut value is a value captured during the test run and entered in the run-time but to a specified location.
EX:-Location in Data Table [Global sheet / local sheet]

27. IF we use batch testing the result shown for last action only in that how can i get result for every action.

u can click on the icon in the tree view to view the result of every action.

28. How the exception handling can be done using QTP

It can be done using the Recovery Scenario Manager which provides a wizard that guides you through the process of defining a recovery scenario. FYI The wizard could be accessed in QTP> Tools-> Recovery Scenario Manager.......

29. How many types of Actions are there in QTP?

There are three kinds of actions:
Non-reusable action—an action that can be called only in the test with which it is stored, and can be called only once.
Reusable action—an action that can be called multiple times by the test with which it is stored (the local test) as well as by other tests.
External action—a reusable action stored with another test. External actions are read-only in the calling test, but you can choose to use a local, editable copy of the Data Table information for the external action.

30. I want to open a Notepad window without recording a test and I do not want to use SystemUtil.Run command as well. How do I do this?

U can still make the notepad open without using the record or System utility script, just by mentioning the path of the notepad "( i.e., where the notepad.exe is stored in the system) in the "Windows Applications Tab" of the "Record and Run Settings window. Try it out.

The QTP (QuickTest Professional) testing process consists of the following main phases:

1. Analyzing your application
The first step in planning your test is to analyze your application to determine your testing needs.

  • What are your application's development environments (for example Web, Java, or .NET)? You will need load QTP add-ins for these environments to enable QTP to identify and work with the objects in your application.
  • What business processes and functionality do you want to test? To answer this, think about the various activities that customers perform in your application to accomplish specific tasks.
  • Consider how to divide these business processes into smaller units. You will be creating actions based on these tasks. Smaller and more modular actions make your tests easier to read and follow, and help ease maintenance in the long run.

  • At this stage, you can already begin creating test skeletons and adding actions to them.

2. Preparing the testing infrastructure
Based on your testing needs, you determine what resources are required and create these resources, accordingly. Resources include shared object repositories containing test objects (which are representations of the objects in your application), function libraries containing functions that enhance QTP functionality, and so on.

You also need to configure QTP settings so that QTP will perform the tasks you need, such as displaying a results report every time you run a test.

3. Building your tests and adding steps to them
After the testing infrastructure is ready, you can begin building your tests. You can create one or more empty tests and add actions to them to create the testing skeletons. You associate your object repositories with the relevant actions, and associate your function libraries with the relevant tests, so that you can insert steps using keywords. You may also need to configure test preferences at this point.

4. Enhancing your test
Inserting checkpoints into your test lets you search for a specific value of a page, object, or text string, which helps you determine whether your application is functioning correctly.

Broadening the scope of your test, by replacing fixed values with parameters, lets you check how your application performs the same operations with multiple sets of data.

Adding logic and conditional or loop statements enables you to add sophisticated checks to your test.

5. Debugging, running, and analyzing your test
You debug a test to ensure that it operates smoothly and without interruption. After the test is working correctly, you run it to check the behaviour of your application. While running, QTP opens the application and performs each step in your test.

You examine the test results to pinpoint defects in your application.

6. Reporting defects
If you have Quality Center installed, you can report the defects you discover to a database. Quality Center is the HP test management solution.

You can use the RegisterUserFunc statement to instruct QuickTest to use your user-defined function as a method of a specified test object class for the duration of a test run, or until you unregister the method.

Note: If you call an external action that registers a method (and does not unregister it at the end of the action), the method registration remains in effect for the remainder of the test that called the action.

To register a user-defined function as a test object method, use the following syntax:

RegisterUserFunc TOClass, MethodName, FunctionName, SetAsDefault

Item

Description

TOClass

Any test object class.
Note: You cannot register a method for a QuickTest reserved object (such as DataTable, Environment, Reporter, and so forth).

MethodName The name of the method you want to register (and display in QuickTest, for example, in the Keyword View and IntelliSense). If you enter the name of a method already associated with the specified test object class, your user-defined function overrides the existing method. If you enter a new name, it is added to the list of methods that the object supports.
FunctionName The name of the user-defined function that you want to call from your test. The function can be located in your test or in any associated function library.
SetAsDefault

Indicates whether the registered function is used as the default method for the test object.
When you select a test object in the Keyword View or Step Generator (tests only), the default method is automatically displayed in the Operation column (Keyword View) or Operation box (Step Generator) (tests only).

Tip: If the function you are registering is defined in a function library, it is recommended to include the RegisterUserFunc statement in the function library as well so that the method will be immediately available for use in any test using that function library.

For example, suppose that the Find Flights Web page contains a Country edit box, and by default, the box contains the value USA. The following example registers the Set method to use the MySet function to retrieve the default value of the edit box before the new value is entered.

Function MySet (obj, x)

dim y

y = obj.GetROProperty("value")

Reporter.ReportEvent micDone, "previous value", y

MySet=obj.Set(x)

End Function

RegisterUserFunc "WebEdit", "Set", "MySet"

Browser("MercuryTours").Page("FindFlights").WebEdit("Country").Set "Canada"

When working with user-defined functions in QTP, consider the following tips and guidelines:

  • For an in-depth view of the required syntax, you can define a function using the Function Definition Generator and experiment with the various options.
  • When you register a function, it applies to an entire test object class. You cannot register a method for a specific test object.
  • If you want to call a function from additional test objects, you can copy the RegisterUserFunc line, paste it immediately after another function and replace any relevant argument values.
  • It is recommended to include the RegisterUserFunc statement in the function library so that the method will be immediately available for use in any component using that function library.
  • To use an Option Explicit statement in a function library associated with your component, you must include it in all the function libraries associated with the component. If you include an Option Explicit statement in only some of the associated function libraries, QTP ignores all the Option Explicit statements in all function libraries.
  • Each function library must have unique variables in its global scope. If you have two associated function libraries that define the same variable in the global scope using a Dim statement or define two constants with the same name, the second definition causes a syntax error. If you need to use more than one variable with the same name in the global scope, include a Dim statement only in the last function library (since function libraries are loaded in the reverse order).
  • By default, steps that use user-defined functions are not displayed in the test results tree of the Test Results window after a run session. If you want the function to appear in the test results tree, you must add a Reporter.ReportEvent statement to the function code. For example, you may want to provide additional information or to modify the component status, if required.
  • If you delete a function in use from an associated function library, the component step using the function will display the “?” icon. In subsequent run sessions for the component or business process test, an error will occur when the step using the non-existent function is reached.
  • If another user modifies a function library that is referenced by a component, or if you modify the function library using an external editor (not QTP), the changes will take effect only after the component is reopened.
  • When more than one function with the same name exists in the function library, the last function will always be called. To avoid confusion, make sure that you verify that within the resources associated with an application area or component, each function has a unique name.
  • You can re-register the same method to use different user-defined functions without first unregistering the method. However, when you do unregister the method, it resets to its original QTP functionality (or is cleared completely if it was a new method), and not to the previous registration.
  • For example, suppose you enter the following statements:
  • RegisterUserFunc "Link", "Click", "MyClick"

    RegisterUserFunc "Link", "Click", "MyClick2"

    UnRegisterUserFunc "Link", "Click"

    After running the UnRegisterUserFunc statement, the Click method stops using the functionality defined in the MyClick2 function, and returns to the original QTP Click functionality, and not to the functionality defined in the MyClick function.

This article discusses how to run QTP scripts in the Scheduled Tasks item in Control Panel. By this method you can schedule individual script or multiple scripts and scripts will run automatically (even when you not at desk):

1. Create a sample QTP Test script. Save it as Testscript in the following location:

C:\Documents and Settings\skalra\Desktop\testscript

2. Create a .vbs file in notepad or in any other script editor to launch QTP with required settings, add-ins etc:


Here is a sample VB script code:

Set qt App = CreateObject("QuickTest.Application")

qtApp.Launch

qtApp.Visible = True

qtApp.Open "C:\Documents and Settings\skalra\Desktop\testscript" 'this is the location of test scripts
Set qtTest = qtApp.Test

Set objResultsOptions = CreateObject("QuickTest.RunResultsOptions")

objResultsOptions.ResultsLocation = strPathname & getTimestamp() 'Suppose you have a function that returns you the timestamp

qtTest.Save

qtTest.Run objResultsOptions

qtTest.Close

qtApp.Quit


Copy the code into notepad and save the file as QTPschedule1.vbs

3. Schedule the QTP:
– Go to Windows “Control Panel” -> “Scheduled Tasks”.
– Click on “Add Scheduled Task” in the “Scheduled Tasks”
– This will start the “Scheduled Tasks Wizard”.
– browse the .vbs file where u placed.
– after selecting, click on the proceed button & select the schedule as u want.

Opening scheduled tasks to modify them

To modify a scheduled task, click Start, click All Programs, point to Accessories, point to System Tools, and then click Scheduled Tasks. The Scheduled Tasks window opens so that you can modify the settings.

Stopping and pausing scheduled tasks

* To stop a running task, right-click the task in the Scheduled Tasks window, and then click End Task. It may take a moment or two for the task to stop. To restart the task, right-click the task and then click Run.
* To pause the task scheduler so that no tasks run until you want them to, click Pause Task Scheduler on the Advanced menu. To permit tasks to run again, click Continue Task Scheduler on the Advanced menu.

NOTE: If you click Pause, the task will run at its next scheduled time.

You can switch to Analog Recording mode only while recording. The option is not available while editing.

To record in Analog Recording mode:

  1. If you are not already recording, click the Record button to begin a recording session.

  2. Click the Analog Recording button or select Automation > Analog Recording. The Analog Recording Settings dialog box opens.
    Analog recording settings

  3. Select from the following options:
    • Record relative to the screen. QTP records any mouse movement or keyboard input relative to the coordinates of your screen, regardless of which application(s) are open or which application(s) you specified in the Record and Run Settings dialog box.

      Select Record relative to the screen if you perform your analog operations on objects located within more than one window or if the window itself may move while you are recording your analog operations.

      Note: When you record in Analog Recording mode relative to the screen, the run session will fail if your screen resolution or the screen location on which you recorded your analog steps has changed from the time you recorded.
      The analog tracking continues to record the movement of the mouse until the mouse reaches the QTP screen to turn off Analog Recording or to stop recording. Clicking on the QTP icon in the Windows taskbar is also recorded. This should not affect your test. The mouse movements and clicks on the QTP screen itself are not recorded.

    • Record relative to the following window. QTP records any mouse movement or keyboard input relative to the coordinates of the specified window.

      Select Record relative to the following window if all your operations are performed on objects within the same window and that window does not move during analog recording. This guarantees that the test will run the analog steps in the correct position within the window even if the window's screen location changes after recording.

      Note: If you have selected to record in Analog Recording mode relative to a window, any operation performed outside the specified window is not recorded while in Analog Recording mode.

  4. If you choose to Record relative to the following window, click the pointing hand and click anywhere in the window on which you want to record in Analog Recording mode. The title of the window you clicked is displayed in the window title box.

  5. Click Start Analog Record.

  6. Perform the operations you want to record in Analog Recording mode.

    All of your keyboard input, mouse movements, and clicks are recorded and saved in an external file. When QTP runs the test, the external data file is called. It tracks every movement and click of the mouse to replicate exactly the operations you recorded.

  7. When you are finished and want to return to normal recording mode, click the Analog Recording button or select Automation > Analog Recording to turn off the option.
  8. If you chose to Record relative to the screen, QuickTest inserts the RunAnalog step for a Desktop item. For example:
    Analog recording-2

    The track file called by the RunAnalog method contains all your analog data and is stored with the current action.

    You can use this track file in more than one action in your test, and also in other tests, by saving the action containing the RunAnalog step as a reusable action. A reusable action can be called by other tests or actions.

    Note: When entering the RunAnalog method, you must use a valid and existing track file as the method argument.

    Tip: To stop an analog step in the middle of a run session, press Ctrl + Esc, then click Stop in the Testing toolbar.

    Tips for Using the Pointing Hand

    • You can hold the left Ctrl key to change the pointing hand to a standard pointer. You can then change the window focus or perform operations in QTP or in your application, such as right-clicking, using the scroll bars, or moving the pointer over an object to display a context menu.

    • If the window containing the object you want to select is partially hidden by another window, hold the pointing hand over the partially hidden window for a few seconds until it comes to the foreground. Then point to and click the required object. You can configure the length of time required to bring a window into the foreground using the General pane of the Options dialog box.

    • If the window containing the object you want to select is fully hidden by another window, or if a dialog box is hidden behind a window, press the left Ctrl key and arrange the windows as needed.

    • If the window containing the object you want to select is minimized, you can display it by holding the left Ctrl key, right-clicking the application in the Windows task bar, and choosing Restore from the context menu.

    • If the object you want to select can be displayed only by performing an event (such as right-clicking or moving the pointer over an object to display a context menu), hold the left Ctrl key. The pointing hand temporarily turns into a standard pointer and you can perform the event. When the object you want to select is displayed, release the left Ctrl key. The pointer becomes a pointing hand again.

You can switch to Low Level Recording mode only while recording a test. The option is not available while editing a test.

To record in Low Level Recording mode:

  1. If you are not already recording, click the Record button to begin a recording session.
  2. Click the Low Level Recording button or select Automation > Low Level Recording.
  3. The record mode changes to Low Level Recording and all of your keyboard input and mouse clicks are recorded based on mouse coordinates. When QTP runs the test, the cursor retraces the recorded clicks.

  4. When you are finished and want to return to normal recording mode, click the Low Level Recording button or select Automation > Low Level Recording to turn off the option.
  5. The following examples illustrate the difference between the same operations recorded using normal mode and Low Level Recording mode.

    Suppose you type the word tutorial into a user name edit box and then press the Tab key while in normal recording mode. Your test is displayed as follows in the Keyword View and Expert View:

    Low Level recording-2

The Keyword View provides an easy way to create, view, and modify tests in a graphical easy-to-use format.

About Working with the Keyword View in HP’s QTP:


The Keyword View enables you to create and view the steps of your test in a modular, table format. Each step is a row in the Keyword View that is comprised of individual, modifiable parts. You create and modify steps by selecting items and operations in the Keyword View and entering information as required. Each step is automatically documented as you complete it, enabling you to view a description of your test in understandable sentences. You can also use these descriptions as instructions for manual testing, if required.

You can use the Keyword View to add new steps to your test and to view and modify existing steps. When you add or modify a step, you select the test object or other step type you want for your step, select the method operation you want to perform, and define any necessary values for the selected operation or statement. Working in the Keyword View does not require any programming knowledge. The programming required to actually perform each test step is done automatically behind the scenes by QTP.

The Keyword View

The Keyword View enables you to create and view the steps of your test in a keyword-driven, modular, table format. The Keyword View is comprised of a table-like view, in which each step is a separate row in the table, and each column represents the different parts of the steps. The columns displayed vary according to your selection.

Keyword View1

Actions are the highest level of the test hierarchy. They contain all the steps that are part of that action, and can include calls to other reusable actions. In the Keyword View, you can use the Action toolbar to view either the flow of all the top-level action calls in the test, or the content of a specific action. You can also display an action by double-clicking it in the Test Flow pane.

You can insert a new action, a call to an action, or a copy of an action, to your test.

Tip: You can copy and paste or drag and drop actions to move them to a different location within a test.

Each action is comprised of steps. Each step is inserted as a row in the Keyword View. For example, the Keyword View could contain the following rows:

Keyword View2

These rows show the following three steps that are all performed on the Welcome: Mercury Tours page of the Mercury Tours sample Web site:

  • tutorial is entered in the userName edit box.
  • An encrypted string is entered in the password edit box.
  • The Sign-In image is clicked.
  • The Documentation column translates each of the steps into understandable sentences.

For every step in the Keyword View, QTP displays a corresponding line of script in the Expert View. If you select a specific row in the Keyword View and switch to the Expert View, the cursor is located in the corresponding line of the script.

You can use the Keyword View to add steps at any point in your test. After you add steps, you can modify or delete them using standard editing commands and drag-and-drop functionality. You can print the contents of the Keyword View to your Windows default printer (and even preview the contents prior to printing).

In the Keyword View, you can also view properties for items such as checkpoints, output values, and actions, use conditional and loop statements, and insert breakpoints to assist you in debugging your test.

The Keyword View can contain any of the following columns: Item, Operation, Value, Assignment, Comment, and Documentation. A brief description of each column is provided below.

Columns Description:

Item Column:

The item on which you want to perform the step (test object, utility object, function call, or statement). This column displays a hierarchical icon-based tree. The highest level of the tree are actions, and all steps are contained within the relevant branch of the tree. Steps performed within the same parent object are displayed under that same object. Function calls, utility objects, and statements are placed in the tree hierarchy at the same level as the item above them (as a sibling).

You can collapse or expand an item in the item tree to change the level of detail that the tree displays.

  • To collapse an item and its sub-items, click the arrow ( ) to the left of the item's icon, press the minus key (-) on your keyboard number pad, press the left arrow key on your keyboard, or right-click the item and select Collapse Sub Tree. The item tree hides all its sub-items and the collapse arrow changes to expand.
  • To collapse all the items in the tree, select View > Collapse All.
  • To expand an item one level or to its previously expanded state, select it and click the arrow (down arrow) to the left of the item icon, press the plus key (+) on your keyboard number pad, press the right arrow key on your keyboard, or right-click the item and select Expand Sub Tree. The tree displays the details for the item and all its first-level sub-items and the expand arrows change to collapse.
  • To expand an item and all its sub-items, select the item and press the asterisk (*) key on your keyboard number pad. The tree displays the details for the item and all its sub-items and the expand arrows change to collapse.
  • To expand all the items in the tree, select View > Expand All.

Note: When you use the +, -, and * keys to expand and collapse the Item tree, make sure that the entire row is selected (by clicking to the left of the item's icon) and that a specific column is not selected, before pressing the required key. Otherwise, the keys will not work.

    Operation Column:

    The operation to be performed on the item. This column contains a list of all available operations (methods, functions, or properties) that can be performed on the item selected in the Item column, for example, Click and Select. The default operation for the item selected in the Item column is displayed by default.

Value Column:

The argument values for the selected operation, or the content of the statement. The Value cell is partitioned according to the number of arguments of the selected operation.

If an argument has a predefined list of values, QTP provides a drop-down list of possible values. If a list of values is provided, you cannot manually type a value in this box.

Assignment Column:

The assignment of a value to or from a variable. For example, Store in cCols would store the return value of the current step in a variable called cCols, which you could then use later in the test.

You can select either Store in or Get from, depending on whether you want to retrieve the value from a variable or store the value in a variable. A Store in X value in the Assignment column is equivalent to an X = <step> line in the Expert View. A Get From X value in the Assignment column is equivalent to a <step> = X line in the Expert View.

Comment Column:

A free text edit box for any information you want to add regarding the step. These are also displayed as inline comments in the Expert View.

Note: You can also enter a comment on a new line below the currently selected step by choosing Insert > Comment.

Note: If you do not see one or more of the columns in the Keyword View, you can use the Keyword View Options dialog box to display them.

Tips for Working with the Keyword View:

  • You can use the left and right arrow keys to move the focus one cell to the left or right, with the following exceptions:
    • In the Item column, the left and right arrow keys collapse or expand the item (if possible). If not possible, the arrow keys behave as in any other column.
    • When a cell is in edit mode, for example, when modifying a value or comment, the left and right arrow keys move within the edited cell.

  • When a Value cell is selected, press Ctrl+F11 to open the Value Configuration Options dialog box.
  • When the entire step is selected (by clicking to its left), use the + key (expands a specific branch), - key (collapses a specific branch), and * key (expands all branches) to expand and collapse the Item tree.
  • When a row is selected (not a specific cell), you can type a letter to jump to the next row that starts with that letter.

The QuickTest Professional test object hierarchy comprises one or more levels of test objects. The top level object may represent a window, dialog box, or browser type object, depending on the environment. The actual object on which you perform an operation may be learned as a top level object, a second level object, for example, Window.WinToolbar, or a third level object, for example, Browser.Page.WebButton.

In some cases, even though the object in your application may be embedded in several levels of objects, the hierarchy does not include these objects. For example, if a WebButton object in your application is actually contained in several nested WebTable objects, which are all contained within a Browser and Page, the learned object hierarchy is only Browser.Page.WebButton.

An object that can potentially contain a lower-level object is called a container object. All top-level objects in the object hierarchy are container objects. If a second-level object contains third-level objects according to the QuickTest Professional object hierarchy, then that object is also considered a container object.

For example, in the step Browser.Page.Edit.Set "David", Browser and Page are both container objects.

When you add a step to your test in the Keyword View, the step is added as a sibling step or sub-step of the currently selected step, according to the QuickTest Professional object hierarchy, as follows:

Keyword View3

Actions help divide your test into logical units, such as the main sections of a Web site, or specific activities that you perform in your application.

A test comprises calls to actions. When you create a new test, it contains a call to a single action. By creating tests that call multiple actions, you can design tests that are more modular and efficient.

An action consists of its own test script, including all of the steps in that action, and any objects in its local object repository.

Each action is stored together with the test in which you created it. You can insert a call to an action that is stored with the test and, depending on the properties of the action, you may also be able to call an action stored with another test.

When you open a test, you can choose to view the test flow (calls to actions) or you can view and edit the individual actions stored with your test.

If you work with tests that include many steps or lines of script, it is recommended that you use actions to divide your test steps. Actions should ideally contain no more than a few dozen test steps.

For example, suppose you want to test several features of a flight reservation system. You plan several tests to test various business processes, but each one requires the same login and logout steps. You can create one action that contains the steps required for the login process, another for the logout steps, and other actions for the main steps in your test. After you create the login and logout actions, you can insert those actions into other tests.

If you create a test in which you log into the system, book one flight, and then log out of the system, your test might be structured as shown—one test calling three separate actions:

Actions in QTP

Actions enable you to parameterize and iterate over specific elements of a test. They can also make it easier to modify steps in one action when part of your application changes.

For every action called in your test, QTP creates a corresponding action sheet in the Data Table so that you can enter Data Table parameters that are specific to that action only.

When you create a QTP Script, it includes one action. All the steps you add and all the modifications you make while editing your test are part of a single action.

You can divide your test into multiple actions by creating new actions and inserting calls to them, by inserting calls to existing actions, or by splitting existing actions. The actions used in the test, and the order in which they are run, are displayed in the Test Flow pane.

There are three kinds of actions:

  • Reusable action. An action that can be called multiple times by the test with which it is stored (the local test), as well as by other tests.

  • Non-reusable action. An action that can be called only in the test with which it is stored, and can be called only once.

  • External action. A reusable action stored with another test. External actions are read-only in the calling test, but you can choose to use a local, editable copy of the Data Table information for the external action. By default, new actions are reusable. You can mark each action you create in a test as reusable or non-reusable. Only reusable actions can be called multiple times from the current test or from another test. You can store a copy of a non-reusable action with your test and then insert a call to the copy, but you cannot directly insert a call to a non-reusable action saved with another test. Inserting calls to reusable actions makes it easier to maintain your tests, because when an object or procedure in your application changes, it needs to be updated only one time, in the original action.
    Two or more tests can call the same action and one action can call another action (this is known as nesting an action). Complex tests may have many actions and may share actions with other tests.

When you run a test with multiple actions, the test results are divided by actions within each test iteration so that you can see the outcome of each action, and you can view the detailed results for each action individually.

When you output a value to the Data Table or add a Data Table parameter to your test, you can specify whether to store the data in the Global data sheet or in the action data sheet.

  • Choosing Global sheet enables you to create a new column or select an existing column in the Global sheet in the Data Table. When you run your test, QTP inserts or outputs a value from or to the current row of the Global data sheet during each global iteration. You can use the columns in the Global data sheet for Data Table output values or Data Table parameters in any action. This enables you to pass information between actions.
  • Each action also has its own sheet in the Data Table so that you can insert data that applies only to that action. Choosing Current action sheet (local) enables you to create a new column or select an existing column in the corresponding action sheet in the Data Table. Note that the name of the action sheet is the same as the name of the relevant action. When you run your test, QTP inserts or outputs a value from or to the current row of the current action (local) data sheet during each action iteration.

When there are parameters or output value steps in the current action's sheet, you can set QTP to run one or more iterations on that action before continuing with the current global iteration of the test. When you set your action call properties to run iterations on all rows, QTP inserts the next value from or to the corresponding action parameter or output value during each action iteration, while the values of the global parameters stay constant.

Note: If you create Data Table parameters or output value steps in your action and select to use the Current action sheet (local) option, be sure that the run settings for your action are set correctly in the Run tab of the Action Call Properties dialog box. You can set your action to run without iterations, to run iterations on all rows in the action's data sheet, or to run iterations only on the rows you specify.

For example, suppose you want to test how a flight reservation system handles multiple bookings. You may want to parameterize the test to check how your site responds to multiple sets of customer flight itineraries. When you plan your test, you plan the following procedures:

  1. The travel agent logs into the flight reservation system.
  2. The travel agent books five sets of customer flight itineraries.
  3. The travel agent logs out of the flight reservation site.

When you consider these procedures, you realize that it is necessary to parameterize only the second step—the travel agent logs into the flight reservation system only once, at the beginning, and logs out of the system only once, at the end. Therefore, it is not necessary to parameterize the login and logout procedures in your test.

By creating three separate actions within your test—one for logging in, another for booking a flight, and a third for logging out—you can parameterize the second action in your test without parameterizing the others.

The Test Flow pane uses the following icons to indicate the different types of item in the hierarchy:

TEST Flow pane in QTP

Tips:

  • You can right-click in the Test Flow pane title bar to view available display options and decide how to display the Test Flow pane. For example, you can auto hide the pane, dock it, or close it.

  • You can click the Test Flow Pane toolbar button to hide or show the Test Flow pane view.
  • Working with Actions in Test Flow Pane

    You can perform the following operations in the Test Flow pane:

    • Display an action in the Keyword View and Expert View. Double-click an action in the Test Flow pane to show only that action in the Keyword View and Expert View.
    • View or hide the sub-nodes in the test. Right-click the Test node in the tree and select Expand All or Collapse All to view or hide the sub-nodes in the tree. You can also select the Test node and press + or * on the keyboard to expand all the nodes in the test, and - to collapse the nodes.
    • Display the test properties. Right-click the Test node in the tree and then select Settings to display the Test Settings dialog box. Details of the test and its path are displayed.
    • View or hide the sub-nodes of an action. Right-click an action in the tree and then select Expand Sub Tree or Collapse Sub Tree to view or hide the sub-nodes in the action. You can also select a sub-node and press + or * on the keyboard to expand the node and - to collapse the node.
    • Display the action properties. Right-click an action in the tree and then select Action Properties to display the Action Properties dialog box. The name of the action and its path are displayed.
    • Display the action call properties. Right-click an action in the tree and then select Action Call Properties to display the Action Call Properties dialog box.
    • Work with the Object Repository. Right-click an action in the tree and then select Object Repository to open the Object Repository window, which displays a tree containing all objects in the current test.
    • Manage Actions. Right-click an action in the tree and then select Copy or Delete.
      • Select Copy to open the Select Action dialog box and create a copy of the action in your test.
      • Select Delete to remove the action from your test.

    • Run the test. Right-click an action in the tree and then select Run from Action or Run to Action to start a run session from the beginning of the selected action, or to run the test until the beginning of the selected action and then pause the run session.
    • Debug your test. Right-click an action in the tree and then select Debug from Action to begin (and pause) a debug session at the beginning of the selected action.
    • Change the run order of actions. You can perform either of the following steps to move a top-level action (a direct child of the test) in the Test Flow Pane tree, and change the run order of the test accordingly. The action and any sub-actions are moved.
      • Right-click a top-level action in the tree and then select Move Up or Move Down. You can also press Ctrl+Up arrow or Ctrl+Down arrow to move an action and its sub-actions.
      • Drag a top-level action in the tree up or down to the required location. When you drag a selected action, a line is displayed, enabling you to see the location in the tree to which the action will be moved. You can only drag top-level actions. Selecting the parent action automatically includes all its sub-actions. You cannot drag a sub-action, nor can you drag a parent action together with only some of its sub-actions.
      • If a test contains a call to an action that does not exist or cannot be found, the action still appears in the tree in the Test Flow pane, and QTP lists the action in the Missing Resources pane.

    The Action toolbar contains options that enable you to view the top-level actions in the test flow or to view any action stored with your test (whether or not the action is actually called in the test). The Action toolbar is automatically displayed above the Keyword View when a reusable or external action is included in test.

    Tip: You can display or hide the Action toolbar in the Keyword View by choosing View > Toolbars > Action.

    In the Expert View, the Action List is always visible and the Expert View always displays the steps for the selected action.

    The Action List enables you to view either the test flow (the calls to the top-level actions in the test) or you can view the steps for a selected reusable or external action. Selecting Test Flow in the Action List displays the overall flow of your test with all the calls to the top-level actions in your test. The test flow also enables you to view and edit the individual steps of non-reusable actions. An action view displays all the details of the selected reusable or external action.

    Actions Toolbar in QTP

    In the test flow, reusable actions are not expandable. You can view the expanded steps of a reusable action by selecting the action from the Action List.

    There are several ways to open the action view for a reusable or external action in the Keyword View:

    • In the Test Flow pane, double-click the action you want to view.
    • Use the Action toolbar to display the top-level Test Flow and then double-click the call to the action you want to view.
    • Use the Action toolbar to display the top-level Test Flow and then highlight the call to the action you want to view and click the Show button.
    • Select the name of the action from the Action List.

    You may have actions that are stored with your test, but are not currently called from your test. (They may be called by other tests, and you can insert calls to these actions from within your test, if needed).

    Actions that are not called in your test are not displayed in the Test Flow Pane, but they are displayed in the Action List. You can select these actions to view or edit their contents.

    If an action is stored with your test but is not called by the test, and you are sure that you do not need the action for this test or any other test, you can delete the action from the test.

    You can create new actions and add calls to them, as needed.

    You can call the new action from your test flow as a top-level action, or you can call the new action from within another action in your test as a sub-action (or nested action).

    You can also split an existing action into two actions.

    To create a new action in your test:

    1. If you want to insert a call to the new action from an existing action in your test, click the step after which you want to insert the new action. To insert a call to the new action from the test flow as a top-level action, click any step.

    2. Select Insert > Call to New Action or click the Insert Call to New Action button on the Insert toolbar. The Insert Call to New Action dialog box opens.
    3. Create Actions
    4. In the Name box, type a new action name or accept the default name. If you rename the action, make sure that the action name is unique (within the test), does not exceed 1023 characters, does not begin or end with a space, and does not contain the following characters: \ / : * ? " < > | % ' ! { }

    5. In the Description box, add a description of the action. You can also add an action description at a later time using the Action Properties dialog box.

      Tip: Descriptions of actions are displayed in the Select Action dialog box. The description makes it easier for you to choose an existing action you want to call.

    6. Ensure Reusable Action is selected if you want to be able to call the action from other tests or multiple times from within this test. By default, this option is selected. You can also set or modify this setting at a later time using the Action Properties dialog box.

    7. Decide where to insert the call to the action by selecting At the end of the test or After the current step. Choosing At the end of the test creates a call from the test flow to a top-level action. Choosing After the current step inserts the call to the action from within the current action (nests the action).

      Note: If the currently selected step is a reusable action from another test, the new action is added automatically to the end of the test (the location options are disabled).

    8. Click OK. A new action is stored with your test and the call to it is displayed at the bottom of the test or after the current step. You can move your action call to another location at a parallel (sibling) level within your test by dragging it to the desired location.

    9. If you inserted the call to the new action while editing your test, make sure your new action is selected before adding steps to it.

    The Action Properties dialog box enables you to define options for the stored action. These settings apply each time the action is called. You can modify an action name, add or modify an action description, and set an action as reusable or non-reusable. For an external action, you can set the Data Table definitions.

    The Action Properties dialog box also enables you to define input and output parameters to be used by the action, and specify the object repositories that are associated with the action. For more information, see Associating Object Repositories with Actions.

    Note: The following sections describe how to define action properties using the Action Properties dialog box. You can also define actions and action parameters in the Expert View.

    You can open the Action Properties dialog box while working with your test by:

    • Right-clicking an action node in the Test Flow pane and selecting Action Properties.
    • Choosing Edit > Action > Action Properties when an action node is highlighted in the Keyword View or displayed in the Expert View.
    • Right-clicking an action node in the Keyword View and selecting Action Properties.

    The Action Properties dialog box always contains the General tab, the Parameters tab, the Associated Repositories tab, and the Used By tab:

    QTP Action Properties

    Note: In addition to the tabs shown above, the Action Properties dialog box for a called external action also contains an External Action tab, and the other tabs are read-only.

    Setting General Action Properties

    You can use the General tab of the Action Properties dialog box to modify the name of an action, add or edit an action's description, or change the reusability status of the action.

    To open the Action Properties dialog box, right-click an action in the Test Flow pane and select Action Properties, or select Edit > Action > Action Properties.

    Note: The name of the action and its path are displayed in the tab. If it was defined with a relative path in QTP, then the path is displayed as .\. If the action is a reusable action or an external action, then Reusable action or External Action is displayed next to the action name.

    The General tab includes the following options:

    Option

    Description

    Name

    The name of the action. By default, the action name is the internal name provided by QTP, such as Action 1. This number is incremented by 1 for each new action that is added to the test.

    You can rename the action, as needed. The action name must be unique (within the test), cannot begin or end with a space, cannot exceed 1023 characters, and cannot contain the following characters: \ / : * ? " < > | % ' ! { }

    Location

    The folder or Quality Center path where the action is stored.

    Description

    You can insert comments about the action. An action description helps you and other testers know what a specific action does without reviewing all the steps in the action. The description is also displayed in the description area of the Select Action dialog box. This enables you and other testers to determine which action you want to call or copy from another test without having to open it.

    Note: You can also add a description when inserting a call to a new action.

    Reusable action

    Indicates whether the action is a reusable action. By default, this check box is selected. A reusable action can be called multiple times within a test and can be called from other tests. Non-reusable actions can be copied and inserted as independent actions, but cannot be inserted as calls to the original action.

    When you change this setting, the action icon changes to a non-reusable action icon or reusable action icon as appropriate. If the steps of the action were expanded, they collapse after changing a non-reusable action to a reusable action. You can view the steps of the reusable action by selecting the action name in the Test Flow pane.

    Notes:

  • If the action is called more than once within the test flow or if the action is called by a reusable action, the Reusable action option is read-only. If you want to make the action non-reusable, remove the additional calls to the action from the test.
  • You cannot expand reusable actions from the test flow view. You can view details of a reusable action by double-clicking the action in the Keyword View, or selecting the action from the Action List.
  • Setting Properties for an External Action

    When you insert a call to an external action, you can choose where you want QTP to store the Data Table data. You can specify this in the External Action tab of the Action Properties dialog box.

    To open the Action Properties dialog box, right-click an action in the Test Flow pane and select Action Properties, or select Edit > Action > Action Properties.

    QTP Action Properties2

    The External Action tab includes the following options:

    Option

    Description

    Data Table parameters

    Indicates where to store the action's Data Table data:

    • To use the original action's data, select Use data stored with the original action (read-only). If you select this option, the data is read-only when viewed from the calling test, and all changes to the original action's data sheet apply when the action runs in the calling test.
    • To use an editable copy of the data in the test's Data Table, select Use a local, editable copy. If you select this option, a copy of the called action's data sheet is added to the calling test's Data Table and is independent of the original action.

    Changes to the original action's data sheet do not affect the calling test even if you insert another call to this action after the action's data sheet is modified.

    If the called action has parameterized steps that rely on new information in the original action's data sheet, enter the relevant column names and required data to the action sheet in the calling test manually.

    Note: When you call an external action, the global data sheet columns and data from the called action's test are always imported as a local, editable copy in the calling test's global data sheet.

    Changes to the original action's global data sheet do not affect the calling test even if you insert another call to this action after the called action's global data sheet is modified.

    If the called action has parameterized steps that rely on new information in the global data sheet, enter the relevant column names and required data to the calling test's global data sheet manually.

    Viewing a List of the Tests and Actions Using this Action

    If your tests are stored in Quality Center and are using the resources and dependencies model, the Action Properties dialog box displays the Used By tab. This enables you to view a list of the tests and actions that contain calls to this particular action. This is the same list that is displayed in the Dependencies tab of the Test Plan module in Quality Center.

    To open the Action Properties dialog box, right-click an action in the Test Flow pane and select Action Properties, or select Edit > Action > Action Properties.

    QTP Action Properties3

    The Used By tab includes the following options:

    Option

    Description

    Test

    Indicates the Quality Center path of the test containing a call to this action.

    Action

    Indicates the internal name of the action containing a call to this action. The internal name is the name that QTP applies to an action by default when the action is created, for example, Action 1. The internal name of the action calling this action is displayed even if the calling action was renamed.

    You can associate object repositories with actions in several ways:

    • You can associate a single action with an object repository by right-clicking the action in the Resources pane and choosing Associate repository with action from the context menu. This opens the Open Shared Object Repository dialog box, enabling you to associate an object repository with the selected action.

    • You can use the Associated Repositories tab of the Action Properties dialog box to associate one or more object repositories with the current action. (Right-click an action in the Test Flow pane and select Action Properties, or select Edit > Action > Action Properties to open the Action Properties dialog box.)

    Associate Object Repositories to Actions

    Tip: You can associate shared object repositories with multiple actions simultaneously, using the Associate Repositories dialog box.

    QTP searches these files to locate test object descriptions when identifying objects in your application. You can associate object repositories that are saved in your file system or in a Quality Center project.

    Note: QTP uses associated object repositories from Quality Center project folders only when you are connected to the corresponding Quality Center project. If you are not connected to the relevant Quality Center project, all associated object repositories that are stored in your Quality Center project are listed as missing in the Missing Resources pane. (QTP always lists any associated object repository that cannot be found in the Missing Resources pane.)

    In addition, if an object repository cannot be found, QTP displays a warning message when you click the Associated Repositories tab in the Action Properties dialog box. QTP also adds a question mark to the missing object repository icon to the left of the missing object repository in the Associated object repositories list.

    You can associate as many object repositories as needed with an action, and the same object repository can be associated with different actions as needed. You can also set the default object repositories to be associated with all new actions in all tests.

    The order of the object repositories in the list determines the order in which QTP searches for a test object description. If there are test objects in different object repositories with the same name, object class, and parent hierarchy, QTP uses the first one it finds based on the priority order defined in the Associated Repositories tab. The local object repository is always listed first and cannot be moved down the priority list or deleted.

    You can enter an associated object repository as a relative path. During the run session, QTP searches for the file in the folders listed in the Folders pane of the Options dialog box, in the order in which the folders are listed.

    Note: If you want other users or HP products to be able to run an action on other computers, and the action's associated object repositories are stored in the file system, you can set the file path as a relative path (click the path once to highlight it, and then click it again to enter edit mode). Any users who want to run this action should then specify the drive letter and folder in which QTP should search for the relative path in the Folders pane of the Options dialog box (Tools > Options> Folders node).

    Important: If you are working with the Resources and Dependencies model with Quality Center 10.00, you should store the action's associated object repositories in the Quality Center Test Resources module and specify an absolute Quality Center path in the Folders pane.

    You can add, delete and prioritize the object repositories associated with the action using the following buttons:

    Associate Object Repositories to Actions2