Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling of function
#1
Not Solved
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?
Reply
#2
Not Solved
You need to pass a string value. Use the below code.

Code:
Call Login("Peter")
Reply
#3
Not Solved
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?
Reply
#4
Not Solved
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>"
Reply
#5
Not Solved
can u please explain a bit?
Reply
#6
Not Solved
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..
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling a function in a Test Script from a function library anupam4j 3 6,127 06-26-2015, 12:31 AM
Last Post: babu123
  Get the function name calling the function Shridevi.Salagare 1 3,750 09-07-2013, 05:07 AM
Last Post: jacosta
  Calling a HP Service Test Skript Gandalf2005 0 2,124 09-05-2012, 07:53 PM
Last Post: Gandalf2005
  Function Calling after executing some steps TaranVohra 2 2,973 06-05-2012, 10:06 AM
Last Post: TaranVohra
  Can you do functions by calling filename or any other better ways? chong67 2 3,206 05-29-2012, 11:41 PM
Last Post: chong67

Forum Jump:


Users browsing this thread: 1 Guest(s)