I need to find a value "Personnel number 60000357 invalid" in Tree node in SAP. Using UFT
' Get the SAPGuiTree object
Set tree = SAPGuiSession("Session").SAPGuiWindow("IDOC").SAPGuiTree("TreeControl")
' Start searching from the root node
i = 0
' Loop until a node is found or we run out of nodes
Do While True
' Try to get the node by index
On Error Resume Next
nodeKey = tree.GetNodeKeyByIndex("", i)
On Error GoTo 0
' If no nodeKey is found, exit the loop
If IsEmpty(nodeKey) Then
Exit Do
End If
' Expand the node to ensure any children are loaded
tree.Expand nodeKey
' Get the text of the current node
nodeText = tree.GetItemText(nodeKey)
' Check if this node's text contains "Purchase Order Completed"
If InStr(nodeText, "Personnel number 60000357 invalid") > 0 Then
found = True
tree.Select nodeKey
Exit Do
End If
' Move to the next node
i = i + 1
Loop
' Report the result
If found Then
Reporter.ReportEvent micPass, "Node Found", "The text 'Purchase Order Completed' was found in the tree."
Else
Reporter.ReportEvent micFail, "Node Not Found", "The text 'Purchase Order Completed' was not found in the tree."
End If
Not work above code.