Micro Focus QTP (UFT) Forums
Calling of function - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Calling of function (/Thread-Calling-of-function)



Calling of function - hamzaz - 07-18-2012

Hi All Smile

My question is

1) I have a

function Login(User)
1)
Code:
Browser("Main Page").Page("Login").Webedit("userName").Set User
2)
Code:
Browser("Main Page").Page("Login").WebButton("Login").Click
End Function


I am calling it as

Login(Peter)
But It is not taking user as a Peter at line 1.
It stucks at line 1.
It should set Peter as user in line 1.

Could you please tell me how can I set my user?


RE: Calling of function - Ankesh - 07-18-2012

You need to pass a string value. Use the below code.

Code:
Call Login("Peter")



RE: Calling of function - hamzaz - 07-18-2012

I dont want to pass a string value , I want to work just like in Java we can add a paremeter in the method like
SelectUser(user)

calling--->SelectUser(peter)
it automatically sets the user,

i wonder how can we do this in QTP?


RE: Calling of function - Ankesh - 07-18-2012

U need to use a call statement if you want to call it as a function
Call FunctionName(Parameters)

You can call them a subroutine too.

FunctionName "<Parameters>"


RE: Calling of function - hamzaz - 07-18-2012

can u please explain a bit?


RE: Calling of function - Shridevi.Salagare - 07-25-2012

This works fine -

Code:
User = "AB"
call Login(User)

function Login(User)
Browser("Main Page").Page("Login").Webedit("userName").Set User
Browser("Main Page").Page("Login").WebButton("Login").Click
End Function

I am nto able to understand your query..could you please elablorate..