how we can call library function in qtp

2,051 views
Skip to first unread message

chinna

unread,
Feb 16, 2010, 8:05:25 AM2/16/10
to Mercu...@googlegroups.com


acutally I developed script for  gmail longing page and i save that script in .vbs
after that i can associate the script using setting options
which code i want write in qtp to run below function


Function gmail_login()
Browser("Google").Page("Google").Sync
Browser("Google").Navigate "http://www.gmail.com/"
Browser("Google").Page("Gmail: Email from Google").WebEdit("Email").Set "chinna"
Browser("Google").Page("Gmail: Email from Google").WebEdit("Passwd").SetSecure "4b794bc217051ee02a5f36e7f80642cf4e1d887102eff397"
Browser("Google").Page("Gmail: Email from Google").WebButton("Sign in").Click
If Browser("Google").Page("New! Google Buzz in Gmail").Link("Nah, go to my inbox").Exist(3) Then
    Browser("Google").Page("New! Google Buzz in Gmail").Link("Nah, go to my inbox").Click
End If
Browser("Google").Page("Gmail - Inbox (5)").Frame("v1").Link("Sign out").Click
Browser("Google").Page("Gmail: Email from Google_2").Sync
Browser("Google").Close
End Function

--
Thanks & Regards,
Chinna,
Mob:9739656841

b sridhar

unread,
Feb 16, 2010, 11:54:26 AM2/16/10
to mercu...@googlegroups.com, pasupule...@gmail.com
Hi Chinna,
 
The function which you have created for Login is not a appropriate solution for a QTP script.
 
Usually in QTP function library (.vbs) is used for generic functions ,Why becoz u could not able to associate the Object Repository to the function library .So,If u specify objects Ex:Browser("Google"),Page("Gmail: Email from Google"),WebEdit("Passwd") in function library file will not work
Example for generic functions:
 
Function DisplayFutureDate()
  DisplayFutureDate=AddDate()
End Function
 
You have to create the Login Reusable action for reusable purpose instead of specifying a login function.
Hoping that i have clarified the use of function library
 
Thanks
Sridhar
 
  
 

 
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Mason W. Foley

unread,
Feb 16, 2010, 12:13:57 PM2/16/10
to mercu...@googlegroups.com
Sridhar makes a good point.  Functions in an external resource should be generic and not dependant on objects unless maybe you are using descriptive programming such that it doesn't need to rely on object repositories.  

Your login can be stored as a reusable action and you can call that action from any of your tests.

Cheers,
MWF

Roman Zilber

unread,
Feb 16, 2010, 10:47:46 PM2/16/10
to mercu...@googlegroups.com
There is nothing good in that point :) Function can be everything:
code referring GUI objects and without them. Everything depends on how
you organize your functions libraries and how you use the functions.
Once you can give a logical name to piece of code, it can be a
function, maybe even should be.

Roman

koteshwar

unread,
Feb 16, 2010, 11:37:56 PM2/16/10
to mercu...@googlegroups.com
yeah , right roman

Regards,
koteshwar .P

Prasad Dev

unread,
Feb 18, 2010, 1:16:59 PM2/18/10
to mercu...@googlegroups.com
Simple Function in VB script
ExecuteFile "Filepath"

e.g.
ExecuteFile "C:/library.vbs"

This will associate library file "library.vbs" at runtime

Regards,
prasad


--

Prasad Dev

unread,
Feb 18, 2010, 1:19:02 PM2/18/10
to mercu...@googlegroups.com
On Thu, Feb 18, 2010 at 11:46 PM, Prasad Dev <forup...@gmail.com> wrote:
Simple Function in VB script
ExecuteFile "Filepath"

e.g.
ExecuteFile "C:/library.vbs"

This will associate library file "library.vbs" at runtime
    then use " CALL Function name" to call a function in action

Vijay Bikkina

unread,
Feb 18, 2010, 1:46:11 PM2/18/10
to mercu...@googlegroups.com

Hi,

 

I have an application where it does lot of math calculations(eg: (x*(y)^z+a*(b)^d)/((e)^f+(c)^m) )  Was wondering if any one know about any math library function I can use or do I need to build my own library file.

 

Regards

VK

mzraz...@gmail.com

unread,
Feb 18, 2010, 2:08:21 PM2/18/10
to mercu...@googlegroups.com
 
Checked this against QTP 10 and your formula worked fine.
If you want to create math library you can do that also.

--

Roman Zilber

unread,
Feb 19, 2010, 10:12:16 PM2/19/10
to mercu...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages