Student Mode Code Display

Welcome to the Fraternity!

Commenting has been enabled. You can comment on all the Code Items now.

Mercury ObjectRepository Util Manipulating Repository Getting Object Hierarchy


Add This Code to My Favourite List
Enter Email

Contributed By admin
Date 2014-07-16 03:25:42

Dim oREPO
' Creating Global array to store the Object hierarchy
Dim arrALL_OBJECT_HIERARCHY() 

'Creating Object repository util object
Set oREPO = CreateObject("Mercury.ObjectRepositoryUtil")

'Loading the Repository
'.Load method loads the tsr file in the Object. 
'It does not associate the Repository file with Action.
oREPO.Load "Repo Path"

'THis function will store all the objects hierarchy in an array
GetAllObjectsHierarchyInArray("")

'Below Function will return the Object in string
sObject =  GetObject("")
Execute "Set oTOObj = "& sObject
oTOObj.CLick 
'or
oTOObj.Set "ABC"

Function GetAllObjectsHierarchyInArray(sRepoPath)
	On error resume next
	Dim oAllObjects
	Dim iCOUNT
	
	'Getting all the Objects in the oAllObjects object
	Set oAllObjects = oREPO.GetAllObjects
	
	'Finding the Total number of object count
	'THis will give all the Object in the Repo
	iCOUNT = oAllObjects.count

	'Re-dimensioning array
	ReDim arrALL_OBJECT_HIERARCHY(iCOUNT)
	
	Dim strParentBrowser
	Dim strParentBrowseAndPage
	
	'Iterating the Repo for Every Object
	For i = 0 to Ubound(arrALL_OBJECT_HIERARCHY) -1
		Set oTO = oAllObjects.Item(i)
		
		'If object is Check point then just write the Checkpoint name
		'Else write micClass and Logical Nmaer of the Object, seperated by comma
		If (Instr(oREPO.GetLogicalName(oTO),".txt") > 0) Then 
			temp = "CHECKPOINT," & oREPO.GetLogicalName(oTO)
		Else
			temp = Trim(oTO.GetTOProperty("micClass") & "," & oREPO.GetLogicalName(oTO))
		End If
		

		'Split the temp variable using ,
		temp2 = Split(temp,",")
		If  Instr(temp,"Browser")=1  Then
			arrALL_OBJECT_HIERARCHY(i) = temp2(0)& "(""" & temp2(1) & """)"
	
			strBrowser = arrALL_OBJECT_HIERARCHY(i)
		ElseIf Instr(temp,"Page")=1 Then
			arrALL_OBJECT_HIERARCHY(i) = strBrowser & "."& temp2(0)&"(""" & temp2(1) & """)"
			
			strParentString = arrALL_OBJECT_HIERARCHY(i)
		Elseif Instr(temp,"Dialog")=1 Then
			arrALL_OBJECT_HIERARCHY(i) = strBrowser & "."& temp2(0)&"(""" & temp2(1) & """)"
			strParentString = arrALL_OBJECT_HIERARCHY(i)
		Elseif Instr(temp,"WinObject")=1 Then
			arrALL_OBJECT_HIERARCHY(i) = strBrowser & "."& temp2(0)&"(""" & temp2(1) & """)"

		Else
			arrALL_OBJECT_HIERARCHY(i) = strParentString &"."& temp2(0) & "(""" &temp2(1) & """)"		
		End If


	Next
	Set oTO = Nothing
	Set oAllObjects  = Nothing
		

	On error GoTo 0
	msgbox arrALL_OBJECT_HIERARCHY(65)
End Function

'Below function is responsible of finding the Obejct hierarchy in the Array
Public Function GetObject(strObject)
	Dim temp
	'Find the object in array arrALL_OBJECT_HEIRARCHY
	temp =  Filter(arrALL_OBJECT_HEIRARCHY,"""" &strObject& """",True,1)
	If Ubound(temp) = -1 Then
		Fn_GetObjectHierarchy = Empty
	Else
		Fn_GetObjectHierarchy = temp(0)
	End If
End Function

Download Above Code

Comments:



Add your comments...
Name : *      
Email : *      
The content of this field will be kept private and will not be shown publicly

Your Comment/Answer *

Enter the text present in this box : *