Friday 4 October 2013

How to see associated library files in QTP using script?

We can iterate all library files attached to test in QTP using below code.

Set qtpApp = CreateObject("QuickTest.Application")
qtpApp.Launch
qtpApp.Visible = True


Set qtLibraries = qtpApp.Test.Settings.Resources.Libraries
' Get the libraries collection object

For each l in qtLibraries
                'here we are printing the names of all library files associated with this test.
                 print l
Next

We can also associate the library file to test at runtime using below code
   qtLibraries.Add "C:\book.vbs"
' Add the library file viz. book.vbs to the collection.

We can also check if given file is associated with the test using below code.

If qtLibraries.Find("C:\myfile.vbs") = -1 Then
    print "library file not found"
 else
    print "library file found"
End If

'Save the test
qtpApp.Test.Save
qtpApp.Quit

 ' Quit QuickTest

Set qtLibraries = Nothing
Set qtpApp = Nothing

This is how we can work with QTP libraries.


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

No comments:

Post a Comment

Please Leave your reply. We value your feedback and inputs

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.