Original Question
I have this expandable folder UIObject that I need to be able to expand to show all the subfolders. It can not be double clicked as this does not expand the folders. I saw from this documentation, https://admhelp.microfocus.com/leanft/en/14.02/NetSDKReference/HP.LFT.SDK~HP.LFT.SDK.Java.ITreeView.html as well as some others that there is a concept of an ITreeView and an ITreeViewNode.
How can I expand this element? I really just need some examples in code of how we can take an object, defeine it as a ITreeView and ITreeView node and expand it.
Result
Even though it is not the best solution, it is possible to do this using the Workaround suggested below and this is the method that made it happen
public void ExpandFolder(int index)
{
IUiObject folder = ViewPage.FolderExplorer.Describe<IUiObject>(new UiObjectDescription
{
ObjectName = "TreeViewItem",
Index = (uint)index
});
var expandButton = folder.AbsoluteLocation;
expandButton.X = expandButton.X + 2;
expandButton.Y = expandButton.Y + 4;
Mouse.Click(expandButton);
GeneralUtilities.Sleep(1);
}
In this case, there was a small drop down arrow to the left of the element. I couldn't identify that, so I identified the folder and manipulated the click. If anyone stumbles upon this and knows a more direct way to do this using LeanFT I would very much like to see an example. If not, and you are here trying to find help - I hope this helps you!
In order to Expand
and Collapse
a Java ITreeView
, these are the steps:
Describe the ITreeView
:
ITreeView treeView = Desktop.Describe<IWindow>(new WindowDescription())
.Describe<ITreeView>(new TreeViewDescription()
{
AttachedText = "Etc"
});
Get one of it's nodes:
ITreeViewNode treeViewNode = treeView.GetNode("someNode");
Expand or collapse it:
treeViewNode.Expand(); treeViewNode.Collapse();
The only expandable object is the ITreeViewNode
(that is, this is the one that has the .Expand
method), and the only way to get to the node is via an ITreeView
, as shown above.
You want to take an UIObject
(I suspect this is what object identification center identified, right?) as an ITreeView
, so that you can call Expand
and Collapse
on it?
This is not possible.
UIObject
, in Web it's a WebElement
, etc.. UIObject
) and adds one more identification property in the processITreeView
case, most probably it's the UIObject
with NativeClass
set as "javax.swing.JTree"
If Object Identification Center didn't identify the expandable object as an ITreeView
, it's because it isn't.
If your goal is just to expand, and manually double clicking works, then you can:
UIObject
;Calculate the coordinates of the point you manually double click, relative to the upper left pixel of the UIObject
. (E.G. 5 pixels down, 5 to the right)
You can approximate it, go for a try and error, or use tools that can help.
Use HP.LFT.SDK.Mouse
class to double click that exact location:
var loc = theUiButton.AbsoluteLocation;
var p = new System.Drawing.Point(loc.X + 5, loc.Y + 5);
Mouse.DoubleClick(p, MouseButton.Left);
The reason why it doesn't work right now is because .DoubleClick
, by default, performs double click in the center of the UIObject
, and I have a hunch that's not where the expandable object is - so you need to provide fine tuning parameters.