Every GUI Test in UFT consists of at least one action. Actions in UFT are units within the test that divide the flow of one test into logical sections. A GUI Test can be divided into multiple actions, to make it more modular, understandable, and efficient tests. Whenever a new test is created in UFT, the flow of the action looks like the below in the Solution Explorer.
You can write the actual steps in the Action editor. Select the required Action tab or double-click the required action in the solution explorer to open the script editor for the required action.
In this article you will learn the following things:
Types of Actions in UFT
On a broader level, there are three types of actions in UFT
Internal and External Actions
- An internal action is an action that is stored in the local test.
- An external action is a referenced call to another action that is stored in a different test.
As the name suggests, only a reusable action can be called multiple times within the same or different tests. By default all actions are reusable. We can make it unreusable if required.
You can also insert a copy of Action in a test if you want to modify the action steps of the calling action. When you copy the action, it becomes an internal action of the test into which it is copied. These copies are not linked to the source test, so any changes in the original action are not updated in the copy.
The Action Properties section is displayed in the properties pane of UFT on the right-hand side.
You can see the Reusable checkbox is checked by default. This makes the action reusable and this action can be called in some other Action of a test. For ease of understanding, I have created a login action for doing login in the HP sample flight application. You can also provide a description of the action in the description field of the properties section.
You can also rename an Action by doing a right-click on the required action in the Solution Explorer and select the Rename menu to give a meaningful name and press the Enter key.
I am renaming Action1 to “Login” Action.
Whenever an action is renamed UFT throws a warning message. Click the Yes button if the action has not been called in any other Action.
Adding a new action to a test
- Calls to new actions. This inserts a new, empty action in your test. The action is an internal action of the test containing it.
- Calls to a copy of an action. This inserts a copy of an existing action in your test.
- Calls to an existing action. This inserts a call to an existing action (an action external to the current test).
Call to a New Action
You will get a new popup window with a default action name and default action location as “At the end of the test”.The Reusable Action checkbox will also be checked by default. I want to make find flight reusable hence I will not uncheck it.
Call to Existing Action
A list of all reusable actions inside the selected Test will be displayed in the Action drop-down.
Now select the Action1 of the current test. You will see that one line of code has been automatically added. At runtime, this RunAction method will call the Login action.
Now if you run the current test, first it will call the Login action to let you in the MyFlight application. Next, the FindFlight action will be called to search for the required flight. After that local action piece of codes will be executed. The flow of execution is also depicted in the test result.
Call to Copy of Action
- File System Object UFT | VBA
- Read, Write and Update Excel File In UFT
- How to Use Environment Variables in UFT
- The Ultimate Cheat Sheet on Step Generator in UFT
- How to Use RegisterUserFunc in UFT with Examples
- Reading and Updating MS Access Database Using ADODB in UFT
- All You Need to Know about Checkpoints In UFT
- Read and Update XML File in UFT | VBA
- VBScript MySQL Database Connection in UFT