Objects and Actions in QTP

Objects

Objects: Objects are the things which contains different properties and methods. For Example: Window is said to be an object which consists of properties such as Exist, GetROProperty and methods such as ChildObjects, Activate, maximize, minimize etc.

Property: Property describes about the object defined, each object has different properties, which is necessary to describe the object, which differentiates the given object with other objects.

For example: If we take a window object, we first have to define to which class it belongs to which is one of the property, it belongs to a window class. Exist is a property which is common to many objects which returns true if that object exists.

Methods: Methods are functions, which are used for changing the properties of the object that is in order to manipulate with the object properties we use.

For example: If we take a window object, Activate is a method used to activate the window object, thus by using Activate method Activate property of the present window object is set to true, thus the window object will be activated if not in activated mode.

Actions

Actions Settings: You can use the Run tab of the Action Call Properties dialog box to instruct QuickTest to run only one iteration on the called action, to run iterations on all rows in the Data Table, or to run iterations only for certain rows in the Data Table.

Iterations using rows: The Run tab includes the following options:

  • Run one iteration only: Run on all rows: Runs the called action with the number of iterations according to the number of rows in the action’s Data Table.
  • Runs the called action only once, using the row in the action’s data sheet that corresponds to the current global iteration number. If the action’s data sheet contains fewer rows than the global sheet, the last row of the action’s data sheet is used for each subsequent test iteration. For example, suppose an action’s data sheet has two rows and the global sheet has four rows. If you choose to run one iteration only for the action and you choose to run iterations on all rows of the global data sheet, then during each iteration of the test, this action will run only one iteration. The data that the action parameters use during each repetition of the test are based on the iteration number for the test. During the first iteration of the test, Data Table parameters in the action take data from the first row of the action’s data sheet. In the second iteration of the test, Data Table parameters in the action take data from the second row of the action’s data sheet. In the third and subsequent iterations of the test, the Data Table parameters in the action continue to take data from the second i.e. the last row of the action’s data sheet
  • Run from row __ to row __ : Runs the called action with the number of iterations according to the specified row range. The Run tab of the Action Call Properties dialog box applies to individual action calls and refers to the rows in the action’s data sheet.

Action Template

Creating an Action Template

If you want to include one or more statements in every new action in your test, you can create an action template. For example, if you always enter your name as the author of an action, you can add this comment line to your action template. An action template applies only to actions created on your computer.

To create an action template:

1. Create a text file containing the comments, function calls, and other statements that you want to include in your action template. The text file must be in the structure and format used in the Expert View

2. Save the text file as ActionTemplate.mst in your \dat folder. All new actions you create contain the script lines from the action template.

Only the file name ActionTemplate.mst is recognized as an action template.

Script Startup

Check for the required add-ins for an application.

Include action template for every test containing script id, Action name, Action Description, Recovery scenario used etc.

Every action, scenario must be specified with an appropriate name.

Check for mandatory input fields for all iterations in the datasheets that are being imported.

Example: The Resources tab of the Test Settings dialog box can be used to associate specific files with the test, such as Data Table files

The option area Other location instructs Quick Test to use data stored in the specified Data Table location. The Data Table can be any Microsoft Excel (.xls) file.

Check for the “Data table iterations” under the test settings for which the test has to be run.
Splitting Actions, Re-usable Actions, Internal/External Actions: Actions help divide your test into logical units, specific activities that you perform in your application.

A test is made up of calls to actions. When you create a new test, it contains a call to a single action or create tests that call multiple actions by inserting calls to them, to make the design more modular and efficient tests.

There are three kinds of actions

reusable action—an action that can be called multiple times by the test with which is stored in 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. They can be modified only in the test with which they are stored.

Non-resuable-actions —an action that can be called only in the test with which it is stored, and can be called only once.

Also See:

Rahnuma Tasnim

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top