Micro Focus QTP (UFT) Forums
Handling Object Repositories dynamically inside For Loop - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: Handling Object Repositories dynamically inside For Loop (/Thread-Handling-Object-Repositories-dynamically-inside-For-Loop)



Handling Object Repositories dynamically inside For Loop - danny2012 - 07-06-2012

Dim obj_rep, obj_col, repository_no, obj_count
Code:
For repository_no = 1 to 10

Set obj_rep = CreateObject("Mercury.ObjectRepositoryUtil")
obj_rep.Load "E:\QTP\user_registration.tsr"

Set obj_col = obj_rep.GetAllObjects()
obj_count = obj_col.Count
Print obj_count

Set obj_col = Nothing
Set obj_rep = Nothing

Next


When I run the above script, only once the obj_count is getting printed. The obj_count for remaining 9 repositories are not printed.
How to overcome this?


RE: Handling Object Repositories dynamically inside For Loop - sshukla12 - 07-09-2012

Hi,

Do u want to load 10 different repositories???? If yes, then change the line
obj_rep.Load "E:\QTP\user_registration.tsr" becuase every time this will load the same OR.

Regards,
Sankalp


RE: Handling Object Repositories dynamically inside For Loop - danny2012 - 07-12-2012

Code:
Dim obj_rep, obj_col, repository_no, obj_count

For repository_no = 1 to 10

Set obj_rep = CreateObject("Mercury.ObjectRepositoryUtil")
obj_rep.Load obj_repository_file_path & current_screen & ".tsr"

Set obj_col = obj_rep.GetAllObjects()
obj_count = obj_col.Count
Print obj_count

Set obj_col = Nothing
Set obj_rep = Nothing

Next


When I run the above script, only once the obj_count is getting printed. The obj_count for remaining 9 repositories are not printed.
How to overcome this?

obj_repository_file_path - would be taken from environment file.
current_screen - would be taken from the OR folder at run time based on a condition.


RE: Handling Object Repositories dynamically inside For Loop - danny2012 - 07-13-2012

Dim obj_rep, obj_col, repository_no, obj_count

For repository_no = 1 to 10

Set obj_rep = CreateObject("Mercury.ObjectRepositoryUtil")
obj_rep.Load obj_repository_file_path & current_screen & ".tsr"

Set obj_col = obj_rep.GetAllObjects()
obj_count = obj_col.Count
Print obj_count

Set obj_col = Nothing
Set obj_rep = Nothing

Next


When I run the above script, only once the obj_count is getting printed. The obj_count for remaining 9 repositories are not printed.
How to overcome this?

obj_repository_file_path - would be taken from environment file.
current_screen - would be taken from the OR folder at run time based on a condition.