Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Functions
#1
Not Solved
I am trying to create functions to perform tasks like Login, Logout, URL Selection, etc. But I cannot seem to find help anywhere. either I am not searching correctly, or QTP cannot do Functions (I highly doubdt)

This is what I have:
Code:
'CTE Testing

Call Function CloseAllOpenWindows ()

Call Function LaunchCTEBrowser ()

'Run tests here
Call Function LoginImageAccessCTE ()

Call Function ActivityReportByReportI ()
'End

Call Function LogoutCTE ()

Call Function CloseAllOpenWindows ()

Do I need to "Call" a function?
Where are Functions suppose to live? (I have them in my Test dir)
Do I need code to tell where these Functions live?
Is there any material around on how to perform Functions?

MUST all of my Functions be in one file? At present, I have each Fjnction going to its own QTP file. If so, and I think it is, how do I assoc 10-20 functions in one file to the test scripts I plan to build. I do not want to have every script to have its own login, close all logout text that I must update. I want one login, one close all and one logout script.

Depending on which scripts I want to run at night, I was hoping to comment or uncomment a script in my Main script above to determine which scripts would execute.

Anyone have a good way to handle this? ;-)
thx
Reply
#2
Not Solved
you can have your functions in a library file. and call the functions in your scripts after adding them to the test as resource.
there is no restriction to keep your file at some particular location, you can place them as per your framework structure.

does that answer to question?

Reply
#3
Not Solved
>> You need not use 'Call' for Function.

>> If you are planning to use relative path,
QTP searches for the file in the current test directory.
Then it will check in in the folders listed in the Tools->Options->Folders
Reply
#4
Not Solved
Generally all resuable functions will kept in .VBS or .QFL Function library and Attach you Function library files to your test and Call those functions.



Eg:
This is what I have:
Code:
'CTE Testing

Call Function CloseAllOpenWindows ()

Call Function LaunchCTEBrowser ()

'Run tests here
Call Function LoginImageAccessCTE ()
Thanks,
Reply
#5
Not Solved
Thx everyone for putting up with me.
My code is such:

Code:
'CTE Testing
Call Function CloseAllOpenWindows ()
Call Function LaunchCTEBrowser ()
Call Function LoginImageAccessCTE ()
Call Function ActivityReportByReportI ()
Call Function LogoutCTE ()

I went to Tools-> Options -> Folders and my Libary is in the topl level folder.
I went to File -> Settings -> Resources and the Associated function libaries is set to LibaryCTE.qfl (Resources -> AssocFuncLib - shows the same)

On Run, I get:
The test run cannot continue due to a syntax error.
Syntax error
Line (3):
Code:
"Call Function CloseAllOpenWindows ()".

My Function Libary has:

Code:
Public Function CloseAllOpenWindows ()

'CLOSE ALL OPEN WINDOWS
Set oBrowser=Description.Create()
oBrowser("micclass").Value="Browser"
Set obj=Desktop.ChildObjects(oBrowser)
For i=0 to obj.Count-1
obj(i).Close
Next

End Function
Reply
#6
Not Solved
To call the Function CloseAllOpenWindows,
just use CloseAllOpenWindows
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Perform some functions whenever QTP Stop button is pressed smartkarthi 2 2,941 08-22-2013, 11:43 AM
Last Post: smartkarthi
  exit parent functions as well Shridevi.Salagare 3 3,598 07-31-2013, 12:15 AM
Last Post: Ankur
  Datatable in functions shwetasharma 2 3,286 03-26-2013, 08:00 AM
Last Post: sams001
  Problem with using two functions in the same action mhanaan 2 2,848 09-14-2012, 10:09 PM
Last Post: mhanaan
  Can you do functions by calling filename or any other better ways? chong67 2 2,961 05-29-2012, 11:41 PM
Last Post: chong67

Forum Jump:


Users browsing this thread: 1 Guest(s)