Action Parameters...Where to use ?

Most of you who have worked on QTP would have heard about action parameters. Several times it so happens that we are aware of a lot of functionalities in QTP but dont know exactly where to use them. For eg: you must have heard RegEx, Parameters, Function Libraries, Output Value etc..etc... you might even know how these work but we just might not know where to use them. The key to a successful QTP developer is to know where to use the right feature. Do I use Text check point or do I use Text Output Value. Should I use data table or should I use Action parameters ? Should I use regular expression or should I use descriptive programming ? There would always be multiple approaches to one problem. Do you know the right one ?
What are action parameters ? Before I explain how this works, let me tell a situation where we need to use this. Lets say you have written a script GetOrderNumber which has say an Action named OrderNumber. In this script, we place an order and get the order number. Thats all that this script does. Now, lets say there are other scripts like CancelOrder, UpdateOrder which need this order number. Since these are all different actions, we need a mechanism to pass a value from one action to another i.e. I want to pass the value of Order Number from the script GetOrderName and use it in the script CancelOrder. Here is where Action parameters help.
In GetOrderName, lets say the order number is stored in a variable called orderNumber. Below are the steps that we need to do now
====== GetOrderNumber script ======
1.Right click on OrderNumber(name of the action) and click Action Properties..
2.Click on parameters tab and set the Output parameter names as say orderNoOut.
So now, the GetOrderNumber script is set to store a value in the above variable for another calling action(like CancelOrder) to use.
3.In Action OrderNumber, you must enter
Parameter("orderNoOut")= orderNumber
Now the output parameter variable is set
4.Lets make this action reusable. Now you are ready to use these in another action in another script
====== CancelOrder Script ======
So now all you need to do in this script is to call the action and pass a variable
1.Insert call to existing action and call GetOrderNumber. Your statement would be
RunAction "OrderNumber [GetOrderNumber]",oneIteration,inputOrderNum
So now inputOrderNum will have the value of the output parameter specified in the action GetOrderNumber
2.Now you have the value of the order number which was passed from the script GetOrdernumber in the variable inputOrderNum
Its that simple. So in this way, when we want a particular value from another action, this is a very simple way of doing this. Try experimenting with this and you are surely going to get a hang of how action parameters help..
I dont want to have any sort of copyright or copyleft in this site but if you are reusing this code in any other site, I would appreciate you to provide this page as a link so that others get a more descriptive explanation of this concept. Your suggestion and comments are always welcome. Cheers !!!
As always,
Your friend in need,

George, Reju

Read Users' Comments (0)

0 Response to "Action Parameters...Where to use ?"

Post a Comment

Visitors

Website Counter