What is the difference between functions and actions in QTP?

Showing Answers 1 - 24 of 24 Answers

SVS Prasad

  • Nov 10th, 2006
 

Reusable Action is peice of code that perform an action on the application , which has application logic.

On the other hand , Functions does not have the application logic . It performs a specific action on the data retrieved from the application and returns the result to the calling action.

For Ex: Your application has TextBox and Button,

Input  : In the textbox we need to enter a numeric value say 5.

Action : Calculate the Factorial

Expected : Factorial value should be displayed in the textbox.

Here setting a value to textbox , performing the click operation and corresponding verification is maintained in the Action , calculation of the factorial value to arrive at the expected output we use a Function.

  Was this answer useful?  Yes

Shiva Prasad.P

  • Nov 13th, 2006
 

  • Action is a thing specific to QTP while functions are a generic thing which is a feature of VB Scripting. Action can have a object repository

    associated with it while a function can't. A function is just lines of code with some/none parameters and a single return value while an action can

    have more than one output parameters.


Where to use function or action?

Well answer depends on the scenario. If you want to use the OR feature then you have to go for Action only. If the functionality is not about any

automation script i.e. a function like getting a string between to specific characters, now this is something not specific to QTP and can be done on

pure VB Script, so this should be done in a function and not an action. Code specific to QTP can also be put into an function using DP. Decision of

using function/action depends on what any one would be comfortable using in a given situation.

  Was this answer useful?  Yes

Bharathi

  • Dec 22nd, 2006
 

Action represents a Testcase that we are implementing, A function is a part of an action. We can define all the functions in a vbs file and use it as a library in QTP

  Was this answer useful?  Yes

anjalireddy

  • Dec 29th, 2006
 

  • Action is a thing specific to QTP while functions are a generic thing which is a feature of VB Scripting. Action can have a object repository

    associated with it while a function can't. A function is just lines of code with some/none parameters and a single return value while an action can

    have more than one output parameters.


Where to use function or action:

Well answer depends on the scenario. If you want to use the OR feature then you have to go for Action only. If the functionality is not about any

automation script i.e. a function like getting a string between to specific characters, now this is something not specific to QTP and can be done on

pure VB Script, so this should be done in a function and not an action. Code specific to QTP can also be put into an function using DP. Decision of

using function/action depends on what any one would be comfortable using in a given situation.

  Was this answer useful?  Yes

vamsi

  • Sep 30th, 2014
 

we can also return multiple values with functions using "Array" function in vbscript. difference is action contains OR but function doesn't contain OR.and Function is a vb script feature and Action is a Tool Feature of QTP.

Functions are faster in execution than actions.

  Was this answer useful?  Yes

Bhavani

  • Mar 16th, 2015
 

1.Actions are used to make the scripts are reusable.
Functions are used to make the logic is reusable
2.Actions contains Functions but functions doesnt contains Actions
3.Actions cant return any value but Functions returns Values

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions