Quality Testing

Quality is delighting customers

Answer the following questions:

What is use of library file and what is contains?

What is difference between writing discripting programming and  writing code in library file?

Thanks in advance,


Views: 155

Replies to This Discussion

A Lib file is basically a VBS file or native QFL format file.
A Lib file will contain the codes or functions that we need to refer across scripts so that we can write it once and share(Associate it) with differnt scripts.

Descriptive programming is a way of writing the code so as to uniquely identify any object on the screen. lets say there is an object where it is logically identified as X("Name") but you suspect that there may be another object with the same name so in order to uniquly identify that object one would use descriptive programming like X(Name:="Name" Index:='1').click
in a nut shell one can resolve the ambiguity. Also in case a control is not identified by QTP but you know some of the properties by yourself there also one can use Descriptive programming.

Third case when one does not want to create a huge OR. e.g. just to verify a text in PDF file we may not want to add all the objects to OR.

Writing code in library is basically craeting some useful routine for your Framework as well as application support.
Hi Malini,

Library File:

Library file is nothing but a VB script file containing code in VB Script format. Library files in QTP are used to declare functions that are needed to be used across actions.

There are two ways to load a Library file in to your test:

1.Specify the Library file in the settings of the script

Create the VB Script file that you need and save to your PC

In QTP go to Test->Settings… Menu as shown in the image below

Go to the Resources tab of the Test Settings window and Click on “+” button. A new line in the list box will appear

Click on “…” button to choose the location of the file

If you specify 2 or more library having a function with same name then QTP will execute the one that comes first i.e. by looking at the order you specify the files. There is no need to specify an order for dependent library file Ex- if file2 uses functions defined in file1 then it is not necessary to specify file1 above file2 any order will work fine.

Click on the “Check Syntax” button to verify that the script is a valid one

The VB script file has been associated with your test and functions it can be used in all the actions present in the script. If you click on the “Set as Default” button then all the library files specified in your current test would be automatically added to the new tests that you create from now on.
Variables, classes, functions etc… declared in the Library files are accessible to all the Actions present with in the test. Specifying library files using this method makes it impossible to restrict the use of the Library to specific actions.

2. Loading the library file at run-time

Instead of specifying the library file in test settings we can load it at run-time by using the execute file function.
ExecuteFile “C:\Documents and Settings\tarun_lalwani\Desktop\Demo.vbs”
This would load all the variables, classes, structures etc… declared in the Library but they would be accessible on in the action that has called the ExecuteFile function i.e. if Action1 loads a library file using ExecuteFile then everything present in the library file would only be accessible to Action1 and not any other action.
To Load a library file present in Test Director the path can be specified as “[Quality Center] Subject\PathInTD”
Once a Library file is loaded using ExecuteFile it can’t be unloaded. It is unloaded automatically when the action ends.
The below table gives advantages of both the methods
Specifying Library File in Test Setting Loading Library File at Run-Time
For declaring Global Variable, Functions, classes etc…
Add all global variables to a VB Script file and specify it in settings. For restricting functions of the library to specific Actions
For loading libraries depending upon conditions at run-time. Ex-
If Condition1 then
ExecuteFile “C:\File1.vbs”
ExecuteFile “C:\File2.vbs”
End If

1.“Mercury QuickTest Professional, User’s Guide, Version 9.1”

Descriptive Programming:

By using Descriptive Programming you can also instruct Quick Test to perform methods on objects without referring to the Object Repository, without referring to the object’s logical name. To do this, you provide Quick Test with a list of properties and values that Quick Test can use to identify the object or objects on which you want to perform a method.

Such a programmatic description can be very useful if you want to perform an operation on an object that is not stored in the object repository. You can also use programmatic descriptions in order to perform the same operation on several objects with certain identical properties, or in order to perform an operation on an object whose properties match a description that you determine dynamically during the test run.
There are two types of programmatic descriptions.
• You can either list the set of properties and values that describe the object directly in a test statement,
• OR you can add a collection of properties and values to a description object, and then enter the description object name in the statement.

When to use Descriptive Programming:

1. When the obeject properties are dynamically changing
2. When the same objects exists on every page like OK, Cancel, Next, Previous, and etc
3. When the Application is not ready for use
4. When Object Repository becomes huge
5. Lots similar obejcts on every page

Please correct me if anything is wrong.


TTWT Magazine





© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service