Highlighting Objects from the Same Class

The code below helps resolve the Object not unique problem. It highlights all the runtime objects that have the same description. The following example can be found in the HighLightObjects.vbs file located in the <UFT One installation folder>\CodeSamplesPlus folder.

' Sample usage: Assume that WinButton description is not unique
HighlightAll Dialog("Options").WinButton("Browse")

' Routine that highlights all the objects
Sub HighlightAll(TestObject)
	Dim Parent, Desc, Props, PropsCount, MaxIndex, i, Objs 
	If IsEmpty(TestObject.GetTOProperty("parent")) Then 
		Set Parent = Desktop 
	Else 
		Set Parent = TestObject.GetTOProperty("parent") 
	End If 
	Set Desc = Description.Create 
	Set Props = TestObject.GetTOProperties 
	PropsCount = Props.Count - 1 
	For i = 0 to PropsCount 
		Desc(Props(i).Name).Value = Props(i).Value 
	Next 
	Set Objs = Parent.ChildObjects(Desc) 
	MaxIndex= Objs.Count - 1 
	For i = 0 to MaxIndex 
		Objs.Item(i).Highlight 
	Next
End Sub