Loading Object Repository at Runtime: "C:/Temp/Mysharedobjectrepository - TSR"
Loading Object Repository at Runtime: "C:/Temp/Mysharedobjectrepository - TSR"
Hi Guys,
I have little confusion about loading OR at runtime. I did some research and came to
know
RepositoriesCollection.Add(SORpath)
Created by GeSHI 1.0.7.20
Code
GeSHi (qtp):
Dim qtApp
Dim strTestPath
qtApp = Nothing
Created by GeSHI 1.0.7.20
4. We can load OR in QTP 6.5-8.2 using automation object model but only one
repository
Thanks
SK
Set app=CreateObject("QuickTest.application")
app.test.settings.resources.ObjectRepositoryPath="Path of the Object Repository"
To load manually -
Note: If you don’t know how to export object repository in .tsr file. Please refer
6th question of this post: QTP FAQS with answers part- 2
Dim qtApp
qtApp.Test.Actions(1).ObjectRepositories.Add "C:\Repository1.tsr"
---------------------------------------------------------------------------------
Note: Above script will add “Repository1.tsr” file to your test during run time.
Please note that this object repository file will be loaded during run time so you
can see it attached only during run time. During stop mode you will not be able to
see attached object repository.
If you want to verify that object repository is added or not during runtime you can
verify. When your script is in running mode just Go to Debug->Pause and then
you can verify by going to Edit->Action->Action Properties and then associated
repository tab.
So Enjoy Learning and let me know if you face any kind of difficulty. You are
always welcome to share your
2. 5.
qtpRep.Add("C:\Sample test.tsr"),1
End If
view plainprint?
1. '*****************************************************************
**********
2. Dim RepositoryFrom
3. Dim ParentObject
4.
5. ObjectRepositoryPath="C:\sudhakar kakunuri\Desktop\OR Automation\SampleO
R.tsr"
6.
7. 'Creating Object Repository utility Object
8. Set RepositoryFrom = CreateObject("Mercury.ObjectRepositoryUtil")
9.
10. 'Load Object Repository
11. RepositoryFrom.Load ObjectRepositoryPath
12.
13. 'Calling a Recursive Function
14. fnPrintObjectNames ParentObject
15.
16. Function fnPrintObjectNames(ParentObject)
17.
18. 'Get Objects by parent From loaded Repository
19. 'If parent not specified all objects will be returned
20.
21. Set fTOCollection = RepositoryFrom.GetChildren(ParentObject)
22. For RepObjIndex = 0 To fTOCollection.Count - 1
23.
24. 'Get object by index
25. Set fTestObject = fTOCollection.Item(RepObjIndex)
26.
27. 'Check whether the object is having child objects
28. If RepositoryFrom.GetChildren (fTestObject).count<>0 then
29.
30. print "Object Logical Name:= "&RepositoryFrom.GetLogicalName(fTe
stObject)
31.
32. print "****************************************************
******"
33.
34. 'Get TO Properties List
35. Set PropertiesColl=fTestObject.GetTOProperties
36.
37. For pIndex=0 to PropertiesColl.count-1
38.
39. 'Print Property and Value
40. Set ObjectProperty=PropertiesColl.Item(pIndex)
41. print ObjectProperty.name&":="&ObjectProperty.value
42.
43. Next
44.
45. print "****************************************************
******"
46.
47. 'Calling Recursive Function
48. fnPrintObjectNames fTestObject
49.
50. else
51.
52. print "****************************************************
******"
53. print "Object Logical Name:= "&RepositoryFrom.GetLogicalName(f
TestObject)
54. print "****************************************************
******"
55. Set PropertiesColl=fTestObject.GetTOProperties
56. For pIndex=0 to PropertiesColl.count-1
57. Set ObjectProperty=PropertiesColl.item(pIndex)
58. print ObjectProperty.name&":="&ObjectProperty.value
59. Next
60.
61. End if
62. Next
63.
64. End Function
65.
66.
Hi All,
Set RepositoryFrom =
CreateObject("Mercury.ObjectRepositoryUtil")
RepositoryFrom.Load "[QualityCenter]
Subject\Sample\objectrep\flight_appli.tsr"
Set TOCollection =
RepositoryFrom.GetChildren(Root)
For i = 0 To TOCollection.Count - 1
Set TestObject = TOCollection.Item(i)
Msg =
RepositoryFrom.GetLogicalName(TestObject)
& vbNewLine
Next
Note: If you are the author of this question and wish to assign points to any of the
answers, please login first.For more information on assigning points ,click here
Hi Sandeep,
Regards,
Shiva
Sandeep,
Regards,
Shiva.
Printable version
Hi Friends,
Below Script to dynamically load the object repository
Folder_Path = Environment.Value("TestDir")
objPath = Folder_Path&"\ObjectRepository\ObjectRepository.tsr"
Dim App
Set App=CreateObject("QuickTest.Application")
Set qtRepositories = App.Test.Actions(App.Test.Actions(1).Name).ObjectRepositories
If qtRepositories.Find(objPath) = -1 Then
qtRepositories.RemoveAll
qtRepositories.Add objPath, 1
End If
Set qtRepositories=nothing
Set App=nothing
QTPExper
View profile More options Apr 28, 11:20 am
t
Hi,
Please correct me
SORpath="C:\ObjectRepository\Repository.tsr"
'RepositoriesCollection.Add(SORpath)
Set QtApp = CreateObject("QuickTest.Application")
Set qtRepositories =
QtApp.Test.Actions("DriverScript").ObjectRepositories ' Getthe object
repositories collection object of the "Login" action
' Add MainApp.tsr if it's not already in the collection
If qtRepositories.Find(SORpath) = -1 Then ' If the repository cannot
be found in the collection
qtRepositories.Add SORpath, 1 ' Add the repository to the
collection
End If
Thanks,
Bhuvan
Report spam
K.Byzoor
Rahuman. View profile More options Apr 28, 5:00 pm
, I.A.S
Hi,
SORpath="C:\ObjectRepository\Repository.tsr"
'RepositoriesCollection.Add(SORpath)
Set QtApp = CreateObject("QuickTest.Application")
qtApp.Visible = True
strTestDir=Environment.value("TestDir")
strActionname=Environment.value("ActionName")
' qtApp.Open strTestDir, False, False '
Set qtRepositories =
qtApp.Test.Actions(strActionname).ObjectRepositories
' Add MainApp.tsr if it's not already in the collection
If qtRepositories.Find(SORpath) = -1 Then ' If the repository cannotbe
found in the collection
qtRepositories.Add SORpath, 1 ' Add the repository to thecollection
End If
Happy Tester,
Byzoor,
Report spam
dines
h View profile More options Apr 28, 6:01 pm
singh
Hi Experts,
what are the usage of that particular segment of code with qtp not in brief
just a single line answer will help me.
Report spam
gop
i View profile More options Apr 28, 7:14 pm
nath
HI Guys,
Report spam
End of messages
« Back to Discussions « Newer topic Older topic »
Here in this Page the Web element is BOLD in Font and Font Size is 10
but i dont find this when i debug this below code...
I searched in the Discussion group and also googled but dint find any
solution..
Kindly Help me...