Object repository
Loading object repository at runtime
« on: February 22, 2008, 11:08:36 AM »
Hi Guys,
I have little confusion about loading OR at runtime. I did some research and came to
know
1. We can load OR in QTP9.2 at run time by
The following example adds the shared object repository to the current action.
Code
GeSHi (qtp):
SORpath = "C:\Temp\MySharedObjectRepository.tsr"
RepositoriesCollection.Add(SORpath)
Created by GeSHI 1.0.7.20
2. We can load OR in QTP 9.1 at run time by
Code
GeSHi (qtp):
Dim qtApp
Dim strTestPath
' full filepath to the test
strTestPath = "C:\Program Files\Mercury Interactive\QuickTest
Professional\Tests\Test1"
' Launch QuickTest
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible
qtApp.Open strTestPath, False ' Open and run the test
Set qtRepositories = qtApp.Test.Actions("Action1").ObjectRepositories ' Get the object
repositories collection object of the "Action1" action
qtRepositories.Add "C:\Program Files\Mercury Interactive\QuickTest
Professional\Tests\Repository2.tsr"
' Release the QuickTest Professional application objectSet
qtApp = Nothing
Created by GeSHI 1.0.7.20
3. We cannot load OR in QTP 9.0 at run time
4. We can load OR in QTP 6.5-8.2 using automation object model but only one
repository
5. We cannot load OR in 6.0-8.2 within script
Am I right or missing something ?
Thanks
SK
How to load the Object Repository
To load the object repository at runtime -
Write following script...
Set app=CreateObject("QuickTest.application")
app.test.settings.resources.ObjectRepositoryPath="Path of the Object Repository"
To load manually -
Goto Test-Settings-resources-select shared for Object Repository Type-Browse the
required Object Repository.
1. How to add object repository in qtp manually.
2. How to add or load object repository in qtp during runtime.
Procedure to add object repository in qtp manually
1. Go to Edit->Action->Action Properties window.
2. Than switch to “Associated Repositories” Tab.
3. Click on “+” sign.
4. Now click on right most side button and add object repository file (in .tsr
format)
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
Procedure to add object repository in qtp during run time:
Just write following lines of code in your script.
--------------------------------------------------------------------------------
Dim qtApp
Set qtApp = CreateObject("QuickTest.Application")
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.
Here is the function to load shared Object repository in 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
Get Objects from Object Repository
Get Objects from Object Repository Using Object Repository Automation
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.
Subject: How to Load the Object
Repository in QTP when it is stored
in QC
shivakumar Feb 4, 2009 13:53:52 GMT
Hi All,
I have a requirement where i need to load the
repository.tsr from QC into QTP using
script.The .tsr file is kept as an attachment in
the test plan module.I am using this code.
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
In the load line itself it is throwing "Load
General Error".I need to use the
RepositoryFrom object to get the logical names
of all the objects in the repository.
Can anyone help me in this regard,it's very
Urgent.
Regards,
Shiva.
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
Sort Answers By: Date or Points
sandeep mandal Feb 5, 2009 06:21:48 GMT Unassigned
I got the same error few days back.
ObjectRepositoryUtil is only available when
QTPlus is installed. This was a separate
installation in QTP 8.2 but from 9.0 it usually
gets installed with QTP. However in some
cases if it does not get installed the we need to
reinstall QTP.
shivakumar Feb 5, 2009 08:28:47 GMT N/A: Question
Author
Hi Sandeep,
Thanks for the response.I am using QTP 9.5.do
you think ObjectrepositoryUtil will not get
installed while installing QTP Or QTP load
function will not support QC path or do we
need to connect to QC using TDConnection
before using this load function(But i already
connect to QC using the connection wizard
available in QTP ,Do i need to connect it
through script also)
Regards,
Shiva
sandeep mandal Feb 5, 2009 09:49:20 GMT Unassigned
Try using Repositories.Add "[QualityCenter]
Subject\Sample\objectrep\flight_appli.tsr"
and check whether QTP is able to add the OR
from QC.
However as I already mentioned, to use ORUtil,
we need to have QTPlus installed. Sometimes it
does not get installed automatically, so we need
to reinstall QTP.
You will see the difference when the same code
will run fine on other machines where QTPlus
is installed correctly.
shivakumar Feb 5, 2009 12:30:24 GMT N/A: Question
Author
Sandeep,
Can you give some detailed information.I am
using RepositoryFrom Object to get the object
properties..But without loading repository using
repositoryFrom .Load i am not able to pick the
object details.For more info please refer the
earlierpost.
Regards,
Shiva.
Printable version
Privacy statement Using t
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
How to add the Repository during Runtime in QTP9.2
Options
4 messages - Collapse all -
Report discussion as spam
QTPExper
View profile More options Apr 28, 11:20 am
t
Hi,
Currently i am using below code.but its throwing error message stating
"Object doesn't support this property or method: 'QtApp.Test.Actions'.
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,
It is working fine for me.
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,
- Show quoted text -
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.
On Thu, Apr 28, 2011 at 5:30 PM, K.Byzoor Rahuman., I.A.S
<byz...@gmail.com>wrote:
- Show quoted text -
--
Thanks & Regards
Dinesh Singh
+91-9310813656
Report spam
gop
i View profile More options Apr 28, 7:14 pm
nath
HI Guys,
Will this help you..
' Below single line of code helps to load Repository at runtime
If RepositoriesCollection.Find("<repo path>")=-1 then
RepositoriesCollection.Add "path"
End If
- Show quoted text -
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...
Dim ctrlWebEl, objWebEl
Set ctrlWebEl = Browser("Send Email").Page("Welcome: Mercury
Tours").WebElement("$398")
Set objWebEl = ctrlWebEl.Object
sColor = objWebEl.currentStyle.fontStyle
msgbox sColor -- Gives Normal
sBackgrColor = objWebEl.currentStyle.backgroundColor
msgbox sBackgrColor
sFontSize = objWebEl.currentStyle.fontSize
msgbox sFontSize
sFontStyle = objWebEl.currentStyle.fontStyle
msgbox sFontStyle
sFontFamily = objWebEl.currentStyle.fontFamily
msgbox sFontFamily
sFontWeight = objWebEl.currentStyle.fontWeight
msgbox sFontWeig
I searched in the Discussion group and also googled but dint find any
solution..
Kindly Help me...