Sunday, July 17, 2011

Work with Shared Object Repository

Shared OR are more advantages than local OR.
1. A OR file which can be associated to any action and any test.
2. If the size of OR grows up, we can split that file to multiple files and associate to action\test.
3. Can be handled very easily i.e we can add local objects in OR to shared, merging of local to shared, merging two shared ORs, we can compare two Shared ORs etc...
4. QTP has so size limit for shared OR, but it recommends the file size is upto 1.5MB for performance reasons.
5. We can handle share ORs easily using OR Manager.

Disadvantages:
1. In a team environment, one team member updates\deletes an object, then all other team members who are working on that object get effected.
2. If we use a single file to hold all shared ORs then, then performance will go down.

Through the tool we can associate the share OR in multiple ways:
1. Edit -> Action -> Action properties -> Associated Repositories -> Browse ur shared OR
2. Resources -> Associate Repositories


We can programmatically add shared ORs in following ways:
Method 1:
Set App=CreateObject("QuickTest.Application")
Set ORS=App.test.Actions("Action1").ObjectRepositories
ORS.Add("c:\sharedOR.tsr")
ORS.Count 'returns the number of shared ORs associated
ORS.Find 'finds the shared OR
ORS.Remove 'removes the associated shared OR

Method 2:
SORpath = "c:\sharedOR.tsr"
RepositoriesCollection.Add(SORpath)
Same above methods can be used with RepositoriesCollection(Add, Count, Find, Remove etc..)

Method 3:
Set RepositoryObj = CreateObject("Mercury.ObjectRepositoryUtil")
RepositoryObj.Load "c:\sharedOR.tsr"
"RepositoryObj" util have more methods than the above.

No comments: