I believe that many QTP newbie’s are confused about Action, Procedures, Function and Subs. Am I right?
No worries! Here we are going to discuss all of them in detail to eliminate all the confusions!
In QTP, there are two ways (on broad level); we can break up the code into logical units. Logical unit is nothing but a 'Piece of code' or ‘a series of VBScript statements’, to perform specific activity in QTP. These two ways are -
1. Actions - specific to QTP
2. Procedures - vbscript provided
Okie.. but what about Functions and Subs? Wait guys! we'll come there.
We know that we use vbscript as scripting language in QTP. (To read about vbscript, Click Here>> )
VBScript has two kinds of procedures: Sub procedure and Function procedure
So, in brief, its goes like this..
Now we know that Action and Procedures are the two things. Procedure is further devided in two types - Function & Sub.
Feeling batter? Great!!
So, Lets start with actions..
1. QTP Actions:-
Action is specific to QTP and not the part of vbscript. Every QTP test has at least one Action(default name is Action1).
Action can have an object repository associated with it. Action can return multiple values in form of 'output parameters'.
2.1. VBScript Sub Procedures:-
A Sub procedure:
- is a series of statements, enclosed by the Sub and End Sub statements
- can perform actions, but does not return a value
- can take arguments
- without arguments, it must include an empty set of parentheses ()
Print "my Sub Procedude"
Print "my Sub Procedure"
How to call Sub Procedures:
To call a Sub, you will use Call statement by enclosing arguments (if any) in parentheses.
The Call statement is not necessary to call a Sub, but if you want to use Call statement (Recommended), you must enclose arguments (if any) in parentheses.
You can call a Sub without using Call statement as well, but not recommended.
2.2. VBScript Function Procedures:-
A Function procedure:
- is a series of statements, enclosed by the Function and End Function statements
- can perform operations and can return a value
- can take arguments that are passed to it by a calling procedure
- without arguments, must include an empty set of parentheses ()
- returns a value by assigning a value to function name itself
Print "my fuction1"
myfunction2=a+b 'assign value to function name
How to call Function Procedures:
Call myfunction1() 'calling 1st function, without any return value
abc=myfunction2(argument1,argument2) 'calling 2nd function, with a return value
Here you call a function called "myfunction2", the function returns a value that will be stored in the variable "abc".
Hope all your confusions are gone! But if you still have any doubts, please post your comments!
it's relly very helpful. thanx a lot!!ReplyDelete
I went through your post. Does it mean that to return multiple vales from the lines of code, we should use action cos function can return only one value and subprocedures cant return a value.
It's not necessity to use actions...in indirectly u can return multiple values by passing parameters byref....Ram
You can either use actions or function to return multiple value.. but in case of function, you need to store all the output values to an array and return that array, bcoz function can return only one value. Refer the below code..
val_sum = a+b
val_sub = a-b
val_div = a/b
myfunction2=arr 'assign value to function name
You can also return multiple values in function just by declaring in function definition..Delete
Function samplefunciton(input1, input2, output1, output2)
output1 = input1 + input2
output2 = input1 * input2
num1 = 2
num2 = 4
Call Function samplefunciton(num1, num2, addnum, multnum)
In above example, addnum will store/return 6 and multnum with store/return 8
this code is not workingDelete
It is good example to return multiple values at a time from calling function
very nice. Thank uReplyDelete
Great piece of info! Thanks!ReplyDelete
Great work.. to clear confusionReplyDelete
thank u for info ..its very usefull.ReplyDelete
hi..clarified.. Thank youReplyDelete
Can u plz explain where to use sub procedure and where to function procedure in real time automation testing ??ReplyDelete
its depend on the what you are trying to achieve from function.. There is no standard rule..ReplyDelete
Nice Explanation . Good Job. Keep it Up.ReplyDelete
I need to know when to use actions and when to use functions real time. Please explain.ReplyDelete
could you explain meReplyDelete
we can call a Sub without using Call statement. and what about function call?
Web Designer in Bangalore
very nice..Thank u :)ReplyDelete
I have a message dialog in QTP with HTML string that displayed over few rows (dynamic, don't know in advance how many rows will be). As a part of each row, there is a date string.ReplyDelete
Hello 02/02/2013 bla,bal
Hello 03/04/2013 bla1 bal2
Hello 04/04/2013 bla3 bla4
I need to find (output) each date in that string and then validate it. If it was just 3 rows - would be easy but it is a html string. Any ideas?
strMsg = "Hello 02/02/2013 bla,bal" & vbcrlf & "Hello 03/04/2013 bla1 bal2" & vbcrlf & "Hello 04/04/2013 bla3 bla4"Delete
Msgbox(strMsg) ' Just to check the source string
arrMsg = split(strMsg,vbcrlf) ' Split value in array with the delimiter crlf ( carriage return and line feed)
' check the upper bound of an array if there are exact 3 values (Array start with 0 to 2 (3 values))
if (ubound(arrMsg)) = 2 then
'Loop through all the rows (lower bound to upper bound)
for cntMsg = lbound(arrMsg) to ubound(arrMsg)
' Again split a single row with the space delimiter and get the message of the 2nd position of an array (in this example 2nd is Date value)
Msgbox split(arrMsg(cntMsg)," ")(1)
Msgbox("Not 3 rows")
example for actions ? can any one tellplease ?ReplyDelete
what are the functions in qtp and actions asked by value labs in interview please helpReplyDelete
There are 3 types of Action in QTPDelete
2.Non- Reusable Actions
2 types of functions
1. Sup Procedures
2. Function Procedures
how to return value from a sub routine?ReplyDelete
Any Help Appreciated.
return value for sub routine is impossible, only function can return.ReplyDelete
by looking at the function can we say it is whether it is a function or procedure?ReplyDelete
check the below ex:
This comment has been removed by the author.ReplyDelete
convert all lowercase characters to uppercase and uppercase characters to lowercase in the string "HEllo WOrLD" in QTPReplyDelete
cho thuê nhà trọ
cho thuê phòng trọ
nhac san cuc manh
số điện thoại tư vấn pháp luật miễn phí
văn phòng luật
tổng đài tư vấn pháp luật
dịch vụ thành lập công ty trọn gói
lý thuyết trò chơi trong kinh tế học
đức phật và nàng audio
hồ sơ mật dinh độc lập audio
đừng hoang tưởng về biển lớn ebook
chiến thắng trò chơi cuộc sống ebook
bước nhảy lượng tử
ngồi khóc trên cây audio
truy tìm ký ức audio
mặt dày tâm đen audio
thế giới như tôi thấy ebook
“Trư tam công tử, ngươi muốn làm gì?” Sắc mặt Lưu Phong hết sức hòa ái nhưng ngữ khí đã có chút phẫn nộ. Dù sao nam nhân trước mặt nữ nhân của mình không thể tỏ ra yếu đuối được.
Ta làm gì không quan trọng nhưng quan trọng là các ngươi đừng lén lút sau lưng ta yêu nhau là được. Công bình cạnh tranh nhưng các người lại sau lưng ta..ta như thế nào chịu được. Tam đầu heo nghĩ trong lòng như vậy nhưng cũng không dám nói ra.
“Lưu đại thiếu gia, chúng ta lúc trước đã nói với nhau sẽ cạnh tranh công bằng cho nên trước khi Vương Đông Đông xuất giá, bất cứ ai cũng không được phép xơi nhũ trư của nàng…”
Tam đầu heo ăn nói quả thực là thô tục. Vương Đông Đông quả thực cảm thấy phẫn nộ, ánh mắt mang theo sự khinh bỉ nhìn hắn nói ra câu nói mà nữ nhân kiếp trước rất hay nói: “Người thật là tầm thường quá.”
Nghe câu nói đó cũng có chút quen tai, Lưu Phong cũng chợt hiểu ra thì ra câu nói này là khi nữ nhân bực bội thường hay nói ra.
“Chu Tam công tử, tất cả mọi người đều là người văn minh. Tại sao trước mặt giai nhân lại ăn nói thô tục như vậy? Ngươi yên tâm, ta là người thành thật. Chuyện ngươi lo lắng sẽ tuyệt không phát sinh.”
Lưu Phong nói xong thì từ Vương Đông Đông cho đến Tam đầu heo, hai người ai cũng cảm thấy cao hứng.
Hi very helpful but having one confusion.ReplyDelete
some time when i declare or define a function. and when i call a function using at that time it gives me a error you can't use parenthesis when calling a sub, so unable to understand why this type error occur because i define a function not an sub in my code
What a fun and upbeat read! I wanna start a blog now after reading this!,ReplyDelete
Wedding Planners in Delhi
شركة تسليك مجارى بالرياضReplyDelete
level تسليك المجاري بالرياض
افضل شركة تنظيف بالرياض
تنظيف شقق بالرياض
شركة تنظيف منازل بالرياض
شركة غسيل خزنات بالرياض
افضل شركة مكافحة حشرات بالرياض
رش مبيدات بالرياض
شركة تخزين عفش بالرياض
شركة تنظيف مجالس بالرياض
تنظيف فلل بالرياض
ابى شركة تنظيف بالرياض
As such, in such a this condition the individuals are not required to purchase any precious online gaming console. Domino QQReplyDelete
This game of the Wild West epic stages an open world action and tends to be the best action game on this system. Agen BolaReplyDelete
Thank you so muchReplyDelete
Event Management Company In Delhi/NCR
We Jubilation Events & Weddings is top most wedding decoraters in delhi and Ncr regions.We make plans for theReplyDelete
outfits,food,theme and other aspects of the wedding, working with our client's suggestions. you'll have to deal with people
involved in catering, entertainment, decorations, and the venue.As specialists in our field, we can play a strong supportive
role in every aspect of your wedding and customise our services to fit your needs, We appreciate all of the planning and
behind-the-scenes work that made our wedding reception the best it could be.We Jubilation Events & Weddings always ready
for your services.
Best Wedding Planners in delhi
Best Wedding Planner in Delhi
Destination Wedding Planner in Delhi
Event Management Companies in Delhi
Wedding Decorators in Delhi
Dj Service in Delhi
Best Dj Service in Delhi
Dj for Wedding
Wedding Planner in delhi
Best Wedding Planners
Wedding in Delhi
Best wedding in Delhi
Event Planners in Delhi
sub procedure will not return any value whereas function procedure can return value but not necessarily. When function procedure can also be used without returning any value. My question here is when function can be used for both the purpose(return value & not returning value) then why sub procedure is required in VBscript.ReplyDelete
building websites is not only fun, but it can also generate an income for yourself. 투데이서버ReplyDelete
Not only do you save yourself some money, but you've also got a much better chance of having the "pick of the bunch" of the recent releases.ReplyDelete
The film royalty payments are a bonus. The producer keeps budgets extremely affordable and streamlined at every phase of production.FmoviesReplyDelete
Not only did they understand it, they were also privy to some of the most impactful action sequences ever put on film.ReplyDelete
This could really provide a spark that the industry desperately needs right now.ReplyDelete
This sort of model will rely on superior technology and online infrastructure to that which we have at the moment however.0123moviesReplyDelete
Film buyers are overextended, have short attention spans, and don't want to waste time.ReplyDelete
Unless their new guardian knows how to deal successfully with the behaviors or are able to help them heal, then often they are returned to the system like orphans in our foster care system. Over and over again. 4animeReplyDelete
Don't write on your poster, even on the back. Marks on the back can sometimes be seen from the other side, taking away from the poster's value. 4animeReplyDelete
Your article is nice and I really want to thank you for sharing this post as it contains a lot of details, keep up this good work.ReplyDelete
I'm awed, I should state. Once in a while do I go over a blog that is both enlightening and drawing in, and stunning, you ve hit the nail on the head. Your blog is basic.. watch movies online free websites without downloadingReplyDelete