Wednesday, July 20, 2011

QTP - How to load Shared Object Repository during runtime?

Here is the VB script to open QTP and load shared Object repository during runtime:

Dim qtp, qtpRep

Set qtp = CreateObject("QuickTest.Application")

qtp.Launch ‘Launches QTP

qtp.Visible = True ‘Makes QTP visible

qtp.New ‘opens a new test

Set qtpRep=qtp.Test.Actions("Action1").ObjectRepositories 'Get the current action's Object repostories collection that is Action1's Object repositories collection

If qtpRep.Find("C:\Sample test.tsr") = -1 Then 'Verifying whether the shared repository is already present in collection list. For a New test this is not required. This would be more helpful for an existing test

qtpRep.Add("C:\Sample test.tsr"),1

End If

Set qtp = Nothing

No comments:

Post a Comment