UFT/QTP – Actions

Actions help to divide your test into logical units. Actions are similar to functions in VBScript, however there are few differences. When you create a test, it include one action by default.

You can divide your test into multiple actions by:

  • Creating new actions and inserting calls to them
  • Inserting calls to existing actions
  • Splitting existing actions

The properties of the action can be accessed by Right Clicking on the Script Editor Window and Selecting “Properties”.

Action properties contains following information –

  • Action Name
  • Location
  • Reusable Flag
  • Input Parameters
  • Output Parameters

Types of Actions

There are three types of actions:

  1. Reusable Action: An action that can be called multiple times by the test with which it is created, as well as by other tests.
  2. Non-Reusable Action: An action that can be called only once in the test with which it has been designed and cant not be used by other tests.
  3. External Action: It is 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 for the external action.

Creating New Action

  • Select “Design > 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 as shown below

  • In the name box, type a new action name or accept the default name.
  • In the description box, add a description of the action or you can add later.
  • Ensure Reusable Action is selected if you want to be able to call action from other test or multiple times from within this test.
  • Decide where to insert the call to the action by selecting “At the  end of the test” or “After the current step”.
  • Click OK. A new action is stored with your test.

Inserting Calls to Actions

You can insert calls to an existing action by inserting a call to a copy of the action or by inserting a call to the existing action.

Inserting Call to copy of Action – When you insert a call to a copy of an action into test, the original action is copied in its entirety, including local repository, checkpoints, parameterization, the corresponding action tab in the Data table, plus any defined action parameters.

Steps to call the Copy of Action –

  • Select “Design > Call to Copy of Action”. The select action dialog box opens.
  • Use From test browse button to select the test
  • Use the Action drop down to select a reusable action.
  • Decide the position where to insert the copy of the action and select “At the end of the test” or “After the current step”.
  • Click OK. The action is inserted into the test as a copy of the action.

Inserting Call to an existing Action

You can insert a call to a reusable action that is stored in your current test or in any other test. Inserting a call to an existing action is like linking to it. You can view the steps of the action in the action view, but you can not modify them.

When the test calling an action uses local repository, the called action’s object repository is read-only in the test calling the action. If the test calling an action uses a shared object repository, the called action uses the same shared object repository as the calling test. In this case, before running the test, confirm that the shared object repository of the calling test contains all the objects that are in the called action otherwise the test may fail.

Steps to insert a call to an existing action  –

  • Select “Design > Call to Existing Action”. The Select Action dialog box opens.
  • Use From test browse button to select the test. The Action box displays all reusable actions in the test you selected.
  • In the Action list, select the action which you want to call.
  • Decide the position where to insert the copy of the action and select “At the end of the test” or “After the current step”.
  • Click OK. The action is inserted into the test.

Action Syntax in Expert View

Calling Actions without Parameters

Syntax – RunAction ActionName, IterationQuantity

For example

  • One Iteration –  RunAction ActionName, oneIteration
  • All row – RunAction ActionName, alliteration
  • Specific range (1-5) – RunAction ActionName, “1-5”

Calling Actions with Parameters

Syntax – RunAction ActionName, IterationQuantity, Parameters

For example RunAction “Action1”, oneIteration, “My Value”, My Variable

Storing Action Return Values –

MyReturnValue = RunAction “Action1”, oneIteration, “My Value”, My Variable

Existing an Action – you can add a line in your script in the Expert view to exit an action before it runs in its entirety.

  • ExitAction – Exits the current action
  • AxitActionIteration – Exits the current iteration of the action
  • ExitRun – Exits the test
  • ExitGlobalIteration – Exits the current global iteration.

 

Leave a Reply Cancel reply