How to create a function in qtp

How do you call a function in QTP?

QTPCall to New Action
  1. Step 1 − Right click on the scripting area and select “Call to New Action”.
  2. Step 2 − In the “Insert Call to New Action” Window, give the test name, description, and also specify if it is a reusable action or not.
  3. Step 3 − You can check the changes, graphically, in the test Name Tab as shown below −

How do you write a function in VBScript?

Creating VBScript Functions
  1. Start by using the Function keyword.
  2. Provide a name for the function (make it concise, but descriptive)
  3. Follow the name with opening and closing brackets.
  4. Add the names of any arguments that the function requires (optional)
  5. Starting on a new line, write the code that makes up the function.
  6. Finish with End Function.

How do you enter a function definition in UFT?

Select Search > Go to > Definition. Right-click the step and select Go to Definition from the context menu. UFT One activates the relevant document (if the function definition is located in another function library) and positions the cursor at the beginning of the function definition.

How do you create and call a function in UFT?

How to use Functions in QTP/UFT in 3 easy steps
  1. Step 1) To create a new function library in HP QTP. Select File > New > Function Library. It opens as a new tab in QTP.
  2. Step 2) Associate the library with your test. Click File > Settings > Resources > Associate Function Library.Click Add.
  3. Step 3) Last step to call the function in your test script.
  4. Important Notes.

What is UFT action?

Each UFT One GUI test consists of calls to actions. Actions are units (within the test) that divide your test into logical sections. By dividing your tests into multiple actions, you can design more modular, understandable, and efficient tests.

How many types of actions are there in UFT?

There are three different Action calls present in UFT: 1. Call to copy of action. 2.

Is UFT easy to learn?

UFT is provided with an object repository and hence development is easy – winner. Selenium does not comprise any such object repository per se but can be managed using UI element user extension. UFT is user friendly with great technical support.

What are the different types of actions in UFT?

There are 3 types of QTP Actions:
  • Reusable – only these can be called multiple times within the same or different tests.
  • Non-Reusable – These cannot be called by any other actions.
  • External Actions – a reusable action when called from another action becomes an external action in the called action.

Can you have actions in function?

So you can let the possibility open to change things from inside your parent or child theme. But to answer your question: Yes, you can call every global function inside another function.

What is the difference between action and function in QTP?

Actions are similar to functions in VBScript; however, there are a few differences. By default, QTP creates a test with one action.


Actions Functions
Actions parameters are passed by value only. Function parameters are passed either by by value or by ref.

How do you change the name of an action in UFT?

How to rename the action using Rename Action dialog box
  1. In Keyword View, select the call to the action we want to rename and select Edit > Action > Rename Action. It will open the Rename Action dialog box.
  2. Write a new name into the New Name box.
  3. Click on the OK button to save the new name.

What is created when you select Edit Action split action?

Select Edit > Action > Split Action, click the Split Action button, or right-click the step and select Action > Split. The Split Action dialog box opens. Select one of the following options: Independent of each other. Splits the selected action into two sibling actions.

What is an action in QTP?

What is Action in QTP? Actions help divide your test into “logical units” or “Business Processes”. Actions help create a script which is more modular and efficient. When a script is newly created it consists of only one action. But you can add more Actions to your Micro Focus UFT Script as per requirements.

How do you add external actions in UFT?

In order to get this dialog on UFT, perform the following:
  1. Import an action from a test by using the menu “Design > Call to Existing Action
  2. Go to the UFT canvas and right click the external action.
  3. Select “Action Properties”

What is the difference between function and action in UFT?

Action is internal to QTP whereas Function is just lines of code with some/none parameters and a single return value. Action can/can not be resuable whereas functions are always reusable. Action Parameter have default values whereas VB script function do not have any default values.

What are the available environment variables types?

There are two types of environment variables: user environment variables (set for each user) and system environment variables (set for everyone).

How do you comment lines in UFT?


But in QTP vb script editor , select required no. of lines & click on “Comment Block” icon Or press “Control + M” thru keyboard.

How do I uncomment UFT?

To uncomment block of statements: Ctrl+Shift+M.

How do I use SendKeys in UFT?

You can use SendKeys to send more than one keystroke at a time. To do this, create a compound string argument that represents a sequence of keystrokes by appending each keystroke in the sequence to the one before it.


  1. plus sign “+”,
  2. caret “^”,
  3. percent sign “%”,
  4. and tilde “~”

How do I launch an application in UFT?

Open the Run dialog (Start -> Run), and learn the “Open” edit field and the “OK” button into the Object Repository. Switch to the Expert View, and manually add the lines to open the Run dialog. Manually enter the lines to enter the information to launch the application, and click the “OK” button of the Run dialog.

When you create an output parameter Quicktest add a column in the?

The output name must be unique in the Data Table sheet. 2) Location in Data Table: When outputting values for a test, specifies whether to add the Data Table column name in the global or current action sheet in the Data Table.

Where do you set the action iteration for a specified action?

The Action Iteration can be specified from “Action Call properties” window which can be opened from Right click menu (context menu) of the particular Action. Now the next step is when we should use both Test iteration and Action Iterations.