# UFT Tutorial | UFT Actions and UFT Function library – An Excellent Guide for UFT 14.x

Testing is now an important phase of the software development life cycle to secure the product’s quality. Also, using of untested product can cause the business loss due to faulty coding. Here automation is playing an essential role in the testing cycle to reduce the efforts and time. There many tools are available for test automation. But, if we consider the broad application coverage, Unified Functional Testing(UFT) tool is very popular for test automation.

In this topic, we are going to learn about the UFT Actions, steps to working with actions, UFT function library and library creation steps.

## UFT Tutorial – Table of Content

UFT Tutorial #1: UFT Overview

UFT Tutorial #2: UFT Setup – Download, Install, License Configuration and ALM Connection

UFT Tutorial #3: UFT Object Repository

UFT Tutorial #4: UFT Actions & Function Library

UFT Tutorial #6: VB Scripting in UFT

UFT Tutorial #7: Step by Step Guide to Create Test Case in UFT

UFT Tutorial #8: Exception Handling in UFT

## UFT Actions:

The UFT action component is acted as a container for writing the scripts. The UFT actions allow us to break the entire automated functionalities into small modules. Any automated test cases should have at least one action by default. But, we can use more than one action based on the test design.

### Different parts of an Action:

The overview of different sections which are available in UFT actions are explained below –

Scripting Area – This section contains the actual test scripts.

Local Object Repository – The technical information of test objects are kept here.

Local DataTable – We can store the test data here which will be used in the test script. It’s similar to the excel sheet.

Properties – Through this section, we can pass the test data as input and read the output.

### Classification of UFT Actions:

The UFT actions can be classified into below three types –

Non-Reusable Actions: This types of actions are treated as the private action for the test script. Thus it cannot be referred from the out side.

Reusable Actions:  The reusable actions are treated as a shared action which can be referred from outside. It is used to share the automated common functionalities with the multiple test cases. During the action creation, the reusable checkbox need to be checked to make it as a reusable component. There is two options are available while referring the reusable actions from external places. The options are “Call to an Existing Action” to link the action or “Call to Copy of an Action” to copy the entire action. The primary purpose is to increase the concept script reusability for better maintenance of test cases.

External Actions: When an action has been called from a different action, is called as external action.

### Reusable and Non-Reusable UFT Actions – Differences:

The scope of non-reusable action is within the same test script, but reusable actions can be accessed from outside test cases.

The non-reusable action is used to create logic of the functional test case, but reusable actions are used to create the reusable components.

### Action Parameters:

The action parameter defines the different input-output data parameters. The input parameters are used to pass the input test data while calling the action and the output parameters are used to return the data from the action to the called actions. We can define the action parameters from the action property section. Two types of action parameters can be defined which are –

Input Parameter – It’s used to pass value to the action as arguments.

Output Parameter – It’s used to return the values from action.

The below example shows the use of input and output parameters of the action –

RunAction “subAction“, oneIteration,inputValue1,inputValue2, outputValue

Here, we are sending the input data through the variables inputValue1 and inputValue2 . From the calling action, the input parameter’s value can be read using Parameter(“inputParam1”) and Parameter(“inputParam2”). Also, the parameter outputParam is used to return the data from action “subAction” through the variable outputValue.

### UFT Actions with Object Repository:

By default, every action contains one local object repository. So the action can use objects from the local repository. Also, we can use any shared object repository to make it more reusable. It is advisable to use a shared object repository for reusable actions.

Steps to Associate Shared Object Repository: The steps to associate repository are mentioned below –

Step1# Rightclick on the action icon from the solution explorer section and click on “Associate repository with action” link.

Step2# Local the path for the shared object repository and click on “Open” button.

Step3# Confirm the “Automatic Relative Path Conversion” dialogue to complete the process. It’s an optional step.

Step4# The the associated shared repository is visible in Solution explorer section. Also, we can open it as the read-only mode by double-clicking on it.

### UFT Actions with DataTable:

Another important component of a UFT action is datatable, which is similar to Microsoft Excel sheet. Datatables are used to store data which are used in test cases.

The UFT datatables are classified into two categories. Those are explained below –

• Local datatable – The every UFT actions are contain one default datatable. This datatable is known as local datatable. The data available in datatable, can be read or update throughout the actions within same test case. The syntax to access the data are,

DataTable.Value(“Param1”,dtLocalSheet) or DataTable.Value(“Param1”,”SheetName”)

Here, dtLocalSheet is only applicable while trying to access the datatable from the container action.

• Global datatable – Apart from local datatable, every test case contain one default datatable which is known as Global datatable. It can be accessed across all the actions using either of the below syntax –

DataTable.Value(“Param1”,dtGlobalSheet) or DataTable.Value(“Param1”,”Global”)

As per the dataTable structure which is shown in above diagram, the script to update data in 2nd row of column “Param1” from column “Param2” of “mainAction” dataTable, will be looks like below –

'Copy data from Param1 to Param2 column.
DataTable.GetSheet(“mainAction”).SetRowCount(2)
myVar = DataTable.value(“Param2”,“mainAction”)
DataTable.value(“Param1”,“mainAction”) = myVar


## Working with UFT Actions:

Three different operations can be performed with the actions –

• Call to New Action – Create a new action.
• Call to Copy of Action – Create a new action by copying areusable action
• Call to Existing Action – Calling an existing reusable action as a reference.

### Call to New Action:

Step1# Click on navigation “Design-> Call to New Action” to open new action creation window.

Step2# Enter below details and click on OK to create a new action.

Name – We need to provide the name of the action.

Reusable Action – We need to check it to make the action as reusable.

Description – It’s an optional field to provide a description of the action.

Location – This field defines the position of new action to be placed after creation.

Step3# Action is created and available in the Solution Explorer section. Now click on “Add” button from Properties section(Parameter tab) to create parameters. After providing the name of Input or Output parameters to create it.

### Call to Copy of Action:

Step1# Click on navigation “Design-> Call to Copy of Action” to open “Select Action” Dialogue window.

Step2# Enter below details and click on OK to create a new action.

From Test – Need to select the container test case for the source reusable action which will be copied.

Action – We can choose the target action from the list box options.

Action Description – It’s an optional field to provide a description of the action.

Edit new action properties – We need to check it if we want to edit the properties.

Location – This field defines the position of new action to be placed after creation.

Step3# Edit the properties such as name, parameters, descriptions etc.

Step4# Click OK to create the action.

### Call to Existing Action:

Step1# Click on navigation “Design-> Call to Existing Action” to open “Select Action” Dialogue window.

Step2# Enter below details and click on OK to create the reference of reusable action.

From Test – Need to select the container test case for the source reusable action which will be copied.

Action – We can choose the target action from the list box options.

Action Description – It’s an optional field to provide a description of the action.

Location – This field defines the position of new action to be placed after creation.

Step3# Reference of existing reusable action will be showing below –

## UFT Function Library:

### Overview of Functions:

A function is a logical block of instructions. UFT supports the vbscripting. So, we can follow the guidelines to create functions in UFT. Any kind of conditional, logical or looping statements can be developed through the functions in UFT which can be reused from any place. Even, we can automate the functional steps through the functions with the help of shared object repository. It’s always advisable to write the functions in UFT function library which is stored in a external path. By associating the function library, we can access any of the functions from any of the UFT test cases.

As UFT allows to develop the functionality, we can replace any reusable action with the help of functions and shared object repository.

### Limitations:

The limitations are explained below for the function library.

• By default, the UFT function library has no dataTable or object repository..
• The UFT functions can not be executed as a standalone. To execute it, it has to be called from any action.
• The function library is an optional component of UFT.
• Always, we need the help of shared object repository or descriptive programming approach to automate any application functionalities.

### Functions and UFT Actions – differences:

• The functions are not build with default object repository and dataTable. But the UFT actions have both the default component.
• The functions can not be executes as an individual component but any action can be executed stand alone.
• It is easy to maintain the functions with compare to actions.
• The use of multiple action can increase the weight of the test scripts which impacts the test execution. But, functions are light weighted which helps to improve the performance.
• Actions are the mandatary component but functions are optional.

### Overview of UFT Function Library:

UFT Function Library is the container of the functions. The user functions can be written in the function library using VBScripting coding method. If we want to work with objects, we need to use the shared object repository.

### Steps to create the UFT Function Library:

Step1# Use the menu option “File->New->Function Library” or “Shift+Alt+N” to open the function library cretion dialogue.

Step2# Enter the location and file name to create the function library with qfl extension.

Step3# Now, we need to associate the function library in the current test case by clicking on the “Associate Function Library with Test” option.

Step4# The function library is now showing under the Solution explorer section. We can write our function using Vbscripting in the library.

### Conclusion:

In this article about UFT Actions and function library, we have learned about about uft actions, classifications and step by step guidance to create different types of UFT Actions and UFT Function Library. Click here to understand more from the Microfocus support portal. If you want to get the flavors of frequently asked UFT interview questions, please click here.

About K Mondal

Hi, I am K. Mondal, I am associated with a leading organization. I am having 12+ years of working experience across domains e.g., application development, automation testing, IT Consultant. I am very much interested in learning different technologies. I am here to fulfill my aspiration and currently contributing as an Author and Website Developer both in LambdaGeeks.
Connect to LinkedIn- https://www.linkedin.com/in/kumaresh-mondal/