Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JavaTree
#1
Solved: 10 Years, 9 Months ago
Suppose I have a JavaTree

-Project
--Node
--City
---city1
---city2
---city3
---city4
--xzm
--BMM
---b1
---b2
---b3
--xx

And I want to know how many nodes are under subtree City or BMM. And no of cities may vary depending upon the input.

can some one please help me out.
Reply
#2
Solved: 10 Years, 9 Months ago
Come on ! NO one ?
Reply
#3
Solved: 10 Years, 9 Months ago
hi perplexed, ok, so I will try to help with some ideas Smile
I think you should use a counter for that, I've used in next way:
Code:
' get the row's count from the dropdown method
Dim Counter
Counter = obj_DropDown.GetROProperty("items count")
MsgBox "There are '" & Counter & "' items under the dropdown!", 0, "Counter Results!!!

where obj_DropDown was described before to use it (I think you know how to do that?!):
Code:
Set obj_DropDown = Browser("URL:=" & Environment.Value("baseUrl")).Page("URL:=" & Environment.Value("baseUrl")).WebList ("select type:=ComboBox Select", "name:=" & obj_Name)

In my sample the URL is got from an XML file(it's the application's URL, you can insert it directly into the code, and the obj_Name is the name of your dropdown, for e.g.:
Code:
' get the row's count from the dropdown
Dim Counter
Set obj_DropDown = Browser("URL:=http://learnqtp.com/.*").Page("URL:=http://learnqtp.com/.*").WebList ("select type:=ComboBox Select", "name:=" & selectCountryDropDown)
Counter = obj_DropDown.GetROProperty("items count")
MsgBox "There are '" & Counter & "' items under the dropdown!", 0, "Counter Results!!!"

P.S. and now play with IF statements to count the under subtree elements and to select the one you want (and to get the sub tree elements from it). Maybe you'll need a second counter for the elements under subtrees?!

Hope that will help you! Wink
Reply
#4
Solved: 10 Years, 9 Months ago
Thanks a lot Lotos. It helped.
I have also written my own script that goes like this :


Public Function findItemCount(ByRef levelID ) // levelID will be the level in the javatree. viz #0;#4;#4 or #i;#j etc.
Code:
Dim itemID
   Dim itemCount
   itemCount = 0
   On Error Resume Next
   Do While true
        itemID = levelID + ";#" + CStr(itemCount)  
        JavaWindow("XXX").JavaTree("JavaTree_obj").Select CStr(itemID)
        If Err.Number <> 0 then
            Exit do
        end if
        itemCount = itemCount + 1

    Loop
    On Error GoTo 0
    
    findItemCount = itemCount
    
End Function
ps. I have tested it and it works fine
Reply
#5
Solved: 10 Years, 9 Months ago
cool men, I am glad that my sample helped you! Smile
Reply
#6
Solved: 10 Years, 9 Months ago
Hi Lotos,
can you please help out with the code on, how to drag an object from one tree structure and drop it in another tree structure. We are working with java based application.

Thanks in advance,
Reply
#7
Solved: 10 Years, 9 Months ago
I think you should use the GetROProperty and assign the get value to a string which will be used in another part. I will try but not sure if it will work, you'll need to adapt the code a little, I does not worked with java applications, and I don't know which are the objects' properties and their values. See next:


Code:
Dim obj_Property1, obj_Property, obj_Property2, obj_Value1, obj_Value2

Set obj_Value1 = JavaWindow("XXX_1").JavaTree("obj_JavaTree1").(GetColumnValue)
Set obj_Value2 = JavaWindow("XXX_1").JavaTree("obj_JavaTree1").(GetColumnValue)
- I'm not sure if GetColumnValue is the right method, maybe you should use: GetItem, to get you value for the specified node, or GetRoProperty.
GetColumnValue returns the text from the specified column in the specified node in the tree.
GetItem returns the value of the node specified by the index.


Code:
Public Function WebElement (obj_Property1, obj_Property2, obj_Value1, obj_Value2)
Set obj_JavaTree2 = Description.Create
    obj_JavaTree2 ("Class Name").value = "WebElement"
    obj_JavaTree2 (obj_Property1).value = obj_Value1
    obj_JavaTree2 (obj_Property2).value =obj_Value2

If JavaWindow("XXX_2").JavaTree("obj_JavaTree2").Exist Then
Reporter.ReportEvent micPass, "The object found", "The java tree object is found under the second Java Window"
Else
Reporter.ReportEvent micFail, "The object not found", "The java tree object with " & obj_Property1 & "=" & obj_Value1 & " and " & obj_Property2 & "=" & obj_Value2 " is missing from the second java Window."
End Function

I don't realy understand what do you mean by saying: to drop it in another tree structure. Maybe you mean to check if it exists under another tree?!
Reply
#8
Solved: 10 Years, 9 Months ago
Hi Lotos,
Thanks a lot for your response. We have attached a screen shot for your understanding regarding the tree structure.
We need to drag an element from one tree structure and drop the element in other tree structure. We will try with the code, that you have given and will get back to you.

Thank You.


Attached Files Image(s)
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to access name of a node in a javatree in UFT ? saniya 0 1,632 07-25-2018, 06:00 PM
Last Post: saniya
  Javatree Problem Omkar87 2 4,694 03-02-2012, 03:09 PM
Last Post: sshukla12
Question JavaTree - Not able to click final links scsvel 1 2,900 01-30-2012, 03:34 PM
Last Post: scsvel

Forum Jump:


Users browsing this thread: 1 Guest(s)