Using External Libraries in QTP

By xerocube | May 15, 2007

I’ve found it necessary to create my own code libraries in QuickTest Pro to handle scenarios that aren’t generally covered by the typical QTP or VBScript APIs. This is a useful process for creating reusable functions that are accessible to your entire automation suite.

To do this, first create your code library, which will be a VBScript file with your methods, variable definitions, and the like. Then, you need to save this file in a location accessible to your scripts, or the machines that will be executing your scripts. This could be a shared folder on your workstation, a shared network folder, or within QualityCenter.

To access your code library, you will need to execute a statement like this:

ExecuteFile “MyCodeLibrary.vbs”

This code segment will execute the MyCodeLibrary.vbs file, thus loading it into memory. This should be located before any code referencing your library. As it stands, this function will use the absolute or relative path for the file you specify.

Using such a library, you can access classes, methods, functions, enumerated types, etc. For instance, I’ve used this method to access a MySQL helper class I wrote allowing me to directly interface with a test database in my current position.

Topics: Code, Quality Assurance, QuickTest Pro, Tech | 1 Comment »

One Response to “Using External Libraries in QTP”

Ryan Says:
March 17th, 2009 at 5:29 pm

Fantastic. I was looking for how to execute a library at the beginning of my script. I couldn’t find it anywhere. Thanks.