- QTP Tutorial
- QTP - Home
- QTP - Introduction
- QTP - Test Automation
- QTP - Environment Setup
- QTP - Record and Play Back
- QTP - Object Repository
- QTP - Actions
- QTP - DataTables
- QTP - Checkpoints
- QTP - Synchronization
- QTP - Smart Identification
- QTP - Debugging
- QTP - Error Handling
- QTP - Recovery Scenarios
- QTP - Environment Variables
- QTP - Library Files
- QTP - Test Results
- QTP - GUI Objects
- QTP - Virtual Objects
- QTP - Accessing Databases
- QTP - Working with XML
- QTP - Descriptive Programming
- QTP - Automation Object Model
- QTP - Frameworks
- QTP - Designing a Framework
- QTP Useful Resources
- QTP - Questions and Answers
- QTP - Quick Guide
- QTP - Useful Resources
- QTP - Discussion
QTP - Library Files
In order to modularize the script, library files are added to the QTP Script. It contains variable declaration, Functions, Classes etc. They enable reusability that can be shared across test scripts. They are saved with an extenstion .vbs or .qfl
A new Library file can be created by navigating to "File" >> "Function Library".
Associating Function Libraries
Method 1 − By using "File" > "Settings" > Resources > Associate Function Library option. Click the "+" button to add Function Library file and add it using the actual path or relative path as shown below −
Method 2 − Using ExecuteFile method.
'Syntax : ExecuteFile(Filepath) ExecuteFile "C:\lib1.vbs" ExecuteFile "C:\lib2.vbs"
Method 3 − Using LoadFunctionLibrary Method.
'Syntax : LoadFunctionLibrary(Filepath) LoadFunctionLibrary "C:\lib1.vbs" LoadFunctionLibrary "C:\lib2.vbs"
Method 4 − Automation Object Model(AOM) - It is a mechanism, using which, we can control various QTP operations outside QTP. Using AOM, we can launch QTP, Open the Test, Associate Function Libraries etc. The following VbScript should be saved with Extension .vbs and upon executing the same, QTP will be launched and test would start executing. AOM will be discussed in detail in the later chapters.
'Launch QTP Set objQTP = CreateObject("QuickTest.Application") objQTP.Launch objQTP.Visible = True 'Open the test objQTP.Open "D:\GUITest2", False, False Set objLib = objQTP.Test.Settings.Resources.Libraries 'Associate Function Library if NOT associated already. If objLib.Find("C:\lib1.vbs") = -1 Then objLib.Add "C:\lib1.vbs", 1 End
To Continue Learning Please Login
Login with Google