Facing problem in selecting nodes in Java tree.

3,359 views
Skip to first unread message

Amit

unread,
Nov 4, 2010, 10:10:26 AM11/4/10
to QTP - HP Quick Test Professional - Automated Software Testing
Hi,

Can anyone pls guide me how to select the nodes in Java Tree.

Thanks
Amit

Aniket Gadre

unread,
Nov 4, 2010, 1:54:40 PM11/4/10
to mercu...@googlegroups.com
Please elaborate your problem.

--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en



--
Best Regards,
Aniket Gadre
Senior SME - Test Automation
Amdocs , Pune.
E-add: aniket...@amdocs.com

Kiran Edupuganti

unread,
Nov 4, 2010, 3:42:46 PM11/4/10
to mercu...@googlegroups.com
can you send the screenshot of Java Tree,
 
Did you try with record mode once or DP once.
 
Regards,
Kiran Edupuganti

--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en



--
Kiran Edupuganti
M.no: 9866424362

bhavin v patel

unread,
Nov 4, 2010, 3:36:08 PM11/4/10
to QTP - HP Quick Test Professional - Automated Software Testing
For JavaTree ,
You can first count number of node items using
counter=JavaWindow("x").JavaDialog("x").JavaTree("x").GetROProperty("items
count")
' you need to spy on object property and find out which method is
giving you actual count
then using counter
ReDim selectItem(coutner)
for i=0 to counter-1

selectItem(i)=JavaWindow("x").JavaDialog("x").JavaTree("x").getItem(i)
JavaWindow("x").JavaDialog("x").JavaTree("x").Select(selectItem(i))
Next

you can also directly select item in javatree like
JavaWindow("x").JavaDialog("x").JavaTree("x").Select "any value
in node with Hierarchy"

for example If you have Javatree like below

Your Name
Your First Name
Your Last Name

you can select
JavaWindow("x").JavaDialog("x").JavaTree("x").Select "Your Name;Your
First Name;Your Last Name"

Let me know if you need any more help.


On Nov 4, 1:54 pm, Aniket Gadre <aniket....@gmail.com> wrote:
> Please elaborate your problem.
>
>
>
> On Thu, Nov 4, 2010 at 7:40 PM, Amit <amitvpandey1...@gmail.com> wrote:
> > Hi,
>
> >  Can anyone pls guide me how to select the nodes in Java Tree.
>
> > Thanks
> > Amit
>
> > --
> > You received this message because you are subscribed to the Google
> > "QTP - HP Quick Test Professional - Automated Software Testing"
> > group.
> > To post to this group, send email to Mercu...@googlegroups.com
> > To unsubscribe from this group, send email to
> > MercuryQTP+...@googlegroups.com<MercuryQTP%2Bunsu...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/MercuryQTP?hl=en
>
> --
> Best Regards,
> Aniket Gadre
> Senior SME - Test Automation
> Amdocs , Pune.
> E-add: aniket.ga...@amdocs.com

Amit Pandey

unread,
Nov 6, 2010, 5:57:22 AM11/6/10
to mercu...@googlegroups.com

Hi Ankit, Bhavin,
 
 I am facing below issues -
 
1.  I want to select the nodes present in the Java Tree ( Pls find the attached snap).
 
        I have already tried .Select "Parentnodes;Childnodes" but it is not working. FYI, I am trying to resolve this thrugh recording.
 
Browser("Cramer6: deuser @ Cramer62").Page("Cramer6: deuser @ Cramer62").Frame("ResourceBrowser").JavaApplet("ScriptableResourceBrowserApple_2").JavaApplet("ResourceBrowserApplet").JavaTree("BrowserTreePane$BrowserTree").Select "#0;#0


2. I also want to Right Click on the Selected nodes.
 
3. I want to check whether the particular nodes is appearing under Javatree after creation.
 
Pls guide asap or let me know the contact no of the person who knows the solution. I can give a call for discussion.
 
Thanks
Amit

Java Tree Issue.JPG

Aniket Gadre

unread,
Nov 6, 2010, 11:27:12 AM11/6/10
to mercu...@googlegroups.com
Ok Amit, Now your issue is pretty clear. Try following below points and you would be able to select your nodes.

1. Expand nodes
In some cases expanding root node expand all nodes. If not, Take item count and loop until you expand all nodes.
(Note: with each expanding node your item count can change. Take this into consideration and expand nodes)

2.Tree has a native method called getSelectionPath or something similar to this. I can provide you exact name on monday.
Start from root node and keep selecting each node. after you select node getSelectionPath. this way you would come to know which path you have selected.

3.Convert your path you wanna select into format of selection path and tally both. if they are same , you are on correct node

For example
I wanted to select Country;State;City. but when I recorded it was in format #0;#1;#3
So I expanded all nodes and selected each node and then got the selection path. The format was [Country , State , City].
So I converted format Country;State;City to  [Country , State , City]. and after selecting each node I used to tally both values.

4.For right clicking a node, Select that particular node, getSelectionPath. There is another native methods called GetPathBounds(path) which takes path as parameter. getSelectionPath will return you path object. Send same obj as parameter to GetPathBounds.
GetPathBouds will return you an object which will have X and Y properties.
Add this X and Y to abs_X and abs_y of tree object. The resultant x and y would be your coordinates where you wanna right click
Use Mercury.DeviceReplay object. Send X , Y and RightButton as parameter and it would rightclick for you on selected node.

This is a generic solution for trees on which we cannot directly select nodes using .Select "Country;State;City" Hope this helps.

Shirish Kabade

unread,
Nov 13, 2010, 12:58:57 PM11/13/10
to mercu...@googlegroups.com
1. Try following to get the tree node exist in the JavaTree

 item_count = JavaTree_Obj.GetItemsCount
 For j = 0 to  item_count -1
If  JavaTree_Obj.getitem(j) = <expNodeName> Then
Result= j-1
Exit for
  End If
 Next
2. If above condition exist then you will get the actual node position i.e. "#" & j then try selecting using normal method

JavaTree_Obj.Select ""#0;#" & j-1

or use 

JavaTree_Obj.Activate""#0;#" & j-1

3. to right click on the selected node after using above method

try following
Set WshShell = CreateObject("WScript.Shell") 
WshShell.SendKeys "^+{F10}"

I guess for Java add-in there is setting that will toggle the Select method selection i.e. NodeID or NodeName, try to google and get the info, if i get info i will let you know.

hope above will work for you.

-Shirish

On Sat, Nov 6, 2010 at 3:27 PM, Amit Pandey <amitvpa...@gmail.com> wrote:

Shirish Kabade

unread,
Nov 13, 2010, 1:06:45 PM11/13/10
to mercu...@googlegroups.com
Please check your QTP settings

Go to Tools->Option-> Java Tab

In Record Items mode section select radio button for JavaTree as By name instead of By index

This will select Node by name not by index.

Enjoy

-Shirish
Reply all
Reply to author
Forward
0 new messages