I see the following search tree in SAP GUI:
I'm trying to verify the contents of that tree, mainly I want to get the text that is displayed for the nodes. I'm using getNodeText() [MicroFocus] to get the text of the node, but it returns an empty string for all nodes.
As an alternative, I tried getItemText() [MicroFocus] with "HierarchyHeader"
as the itemName
parameter. Still no luck.
So from Silk4J point of view, the tree looks like this, which makes it impossible to identify the nodes:
I even tried to identify nodes using the icon returned by getNodeAbapImage() [MicroFocus], but this also returns an empty string.
For now I don't have any chance to identify the nodes in the search tree. Is there a way to get the node text? A workaround is also acceptable.
I am using Silk4J 15.5 Hotfix 5 (15.5.5.7099).
I used the SAP script recorder to see what script it generates when I click some nodes and the following was recorded:
session.findById("wnd[0]/...").selectItem " 2","&Hierarchy"
Then I tried to use "&Hierachy"
instead of "HierarchyHeader"
in getItemText()
and it worked.
Next, I figured out where the text "&Hierarchy"
comes from so that I don't have a hard-coded magic constant. I found that it is getColumnNames().get(0)
. Since the tree type is COLUMN
with only one column displayed, the index should always be 0
.
Since getNodeText()
works for some other trees in SAP, I have implemented the following fallback strategy:
@Override
public String getNodeText(String nodeKey)
{
String nodeText = tree.getNodeText(nodeKey);
if (StringUtils.isEmpty(nodeText))
{
nodeText = getItemText(nodeKey, tree.getColumnNames().get(0));
}
return nodeText;
}