Forum Discussion
Hi ,
Find the label and get width and height
For example
TreeView.Click(label.width+10/2,label.Height/2);
another way,
Place selection on TreeItem,Press Space Key [Space],it will expand.
Regards,
Karthick Raj P
- tristaanogre8 years agoEsteemed Contributor
karthick7 wrote:
Hi ,
Find the label and get width and height
For example
TreeView.Click(label.width+10/2,label.Height/2);
another way,
Place selection on TreeItem,Press Space Key [Space],it will expand.
Regards,
Karthick Raj P
These are some good alternatives. However, we might be able to get this to work if we know what kind of TreeView it is. What is sounds like is that the treeview object is not being identified as a known component type.
This is the list of supported Angular JS controls. https://support.smartbear.com/testcomplete/docs/general-info/supported-technologies/controls/angularui.html
If your component is not one of these, then either go with karthick7 suggestion or see if we can map the object to something similar in your project object mapping (Tools | Current Project Properties)
- Colin_McCrae8 years agoCommunity Hero
Looking at the TC docs, Angular JS Trees are not supported directly.
But I had a look at an example one. The one on here: https://angular-ui-tree.github.io/angular-ui-tree/#/basic-example
... and I was able to interact with it easily enough. The tree itself shows as a top level control. All it's nodes show as child items. All text within the nodes was visible and I was able to search by it. And the clickable controls (expand, add, remove) within each node were all accessible and usable. I'd be happy I could build my own handler function to allow me to use them without too much trouble.
Of course, this is based on an example one I happened to find online. I have no idea if the one you're dealing with behaves the same way.
- Colin_McCrae8 years agoCommunity Hero
Same goes for this example one: http://www.jqueryrain.com/?KIVkhqxl
It was all there. Think they implemented it slightly differently as it was a little more awkward to interact with. But again, if I took the time, I could build my own handler for it.
Not all controls are supported and do everything you want out of the box. Sometimes you need to build your own solutions I'm afraid. This appears to be one of them. But, going by the examples I can find, it appears to give you all the properties and methods you should need to do exactly that.
- ameykhopade8 years agoContributor
Hi,
can you tell me what you mean by label and treeview (which objects)
I tried something similar
On Error Resume Next strLongName = func_RetrieveLongName(Driver2)
' here from "func_RetrieveLongName"
I am getting the full of the object from a excel sheet as I am doing this as data driven, that full name is
Sys.Browser("iexplore").Page("*").Panel(1).Panel(0).Panel(0).Panel(1).Panel(0).Panel(0).Panel(0).Panel(0).Panel(1) panel(1) in having only one child i.e for the "Routine" label as panel(0) (attached image img.PNG)
Set Obj = eval(strLongName) Dim x,y x = Obj.Left + Obj.Width / 2 y = Obj.Top + Obj.Height / 2 ' Obtains the IMG object by coordinates Set a= Sys.Desktop.ObjectFromPoint(x, y) If a.Exists Then a.Click Else Call Log.Warning("Unable to simulate the click.") End If If Err.Number > 0 Then Log.Message Err.Description End if
for the a.click action I am getting message "waiting until the overlapped window becomes visible"
as my tree view in on the Modual Dialogue Box
so i guess I need to get the coordinates of that dialogue box I am not sure how to get them any idea on this?
and is the code i have written correct?
thanks,
Amey
- Colin_McCrae8 years agoCommunity Hero
Close.
Hard to say what's happening exactly as I'm not sure exactly which object you are passing your function. But you are using the wrong information, and clicking in the wrong place. You're also trying to interpret and object by moving the mouse to it and getting the object under the mouse at that point? If there are overlays and things in place, that could all go horribly wrong.
Anyway.
Using the example here: http://www.jqueryrain.com/?KIVkhqxl
As it looks most similar to yours. (But may not be. It looks like there are various ways of building these and this looks closer than the other example I found.)
This code (VBScript - which is what you're using by the look of it):
Function ClickNode() Dim searchPROP(1) Dim searchVAL(1) searchPROP(0) = "contentText" searchPROP(1) = "className" searchVAL(0) = "root2*" searchVAL(1) = "node-wrapper" Set tree = Sys.Browser("iexplore").Page("http://www.jqueryrain.com/?KIVkhqxl").Frame(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel(1).Panel(1).Panel(0).Panel(1).Panel(0).Panel(0).Panel(3).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Frame(0).Panel(0) Set node = tree.FindChild(searchPROP, searchVAL, 2) y = node.Height / 2 x = 4 node.Click x,y End Function
Will expand/contract the second node in tree on that example page.
It's simple enough.
Assigns the tree container to an object.
Searches for the node it wants within the tree using the content text and class name. You have to use two parameters to make sure you get the single line. If you don't, and search using text only, it will find the container wrapper for the entire node (including child nodes if it's open) and the co-ordinates could be wrong (they'll be wrong if the node is expanded). You have to isolate it to the single line within the node. With a "*" in the text search part as it's only the first, main text, part I'm after.Assigns that to an object.
Gets the height of the node and divides by 2 to get the mid-point.
Don't need the width as we know it's the little arrow on the left we want to click so it's hard-coded to 4.The height on this is example is 29. So call it 15 once divided by 2.
It then applies the Click on the node it found at point 4 , 15 within the object. So 4 pixels in halfway up.
And the node expands. Or contracts. Depending what state it's currently in. (You can also check that.)
If you change the text search string to "asyncroot*", it will do the same to the third node. Etc etc.
You would need to add to this. Pass in parameters. Add some error handling. Put it in some sort of stepped loop if you need to go several levels deep. But this demonstrates the basics of clicking a single node. Open the sample I linked to in IE and try it. (Should work in Chrome as well but it looks like Chrome updated itself last night and I'm going to have to update or patch my TestComplete install to get it working again. Sigh.)
- ameykhopade8 years agoContributor
thanks alot.
this should definitely work.
can you just tell me what kind of check should I do to check if the node is currently expanded or not.
thanks,
amey