Getting a child node of a javatree using GetItem

1,449 views
Skip to first unread message

Vishal

unread,
Feb 24, 2009, 9:12:08 AM2/24/09
to QTP - HP Quick Test Professional - Automated Software Testing
Hi

I am trying to get the text/label of a child node of a javatree but
the GetItem method is not working for the child node.

For example, I have a tree with first node as "Parent1" and it has a
child node "Child1"
GetItem method is returning only the parent node value.
JavaTree("tree").GetItem("0") gives me "Parent1"
but JavaTree("tree").GetItem("0;0") gives an error that the function
has invalid arguments.

I am able to use the select method to select the node using the
separator
JavaTree("tree").Select "Parent1;Child1"

Will really appreciate if anyone can provide some help/workaround.


Thanks
Vishal

mi...@mikepietsch.com

unread,
Feb 24, 2009, 12:28:00 PM2/24/09
to Mercu...@googlegroups.com, Vishal, QTP - HP Quick Test Professional - Automated Software Testing
Vishal,

If I remember correctly (don't have QTP in front of me) GetItem only
takes an index as a parameter. While everything in VBScript is a
variant, the implication of an index is an int value. If you passed
in "0", the variant string should be cast to an int 0, but "0;0" would
not be cast to a int value, so the complaint that there is an invalid
argument would be an appropriate response to the line:

JavaTree("tree").GetItem("0;0")

Since you already know that but JavaTree("tree").GetItem("0") is
valid, I might point out that it would be more correct to write:

JavaTree("tree").GetItem(0)

However, none of that solves any of your issue. My initial thought(s)
would be

1) Look at the child items as a collection and loop through the
collection, and evaluate each to find the one or more child items you
are looking for.

- or -

2) use a description object to describe the child node that you are
looking for and work with it directly.

Mike Pietsch

Vishal

unread,
Feb 25, 2009, 2:44:48 AM2/25/09
to QTP - HP Quick Test Professional - Automated Software Testing
Thanks Mike!

I tried viewing the child nodes as child objects of the JavaTree
object. But it doesnt work.
QTP doesnt identify those child nodes as children JavaTree Object, but
it identifies them as Items( or we may call them sub-items).

The strange thing is that I am able select the child node by using the
separator-
JavaTree("Tree").Select("Parentnode";"childnode")

But the same thing fails for GetItem, even though the QTP user guide
says it should work !

I am tryiing to reach the Mercury support to see if they can help.


Thanks,
Vishal

On Feb 24, 10:28 pm, m...@mikepietsch.com wrote:
> Vishal,
>
> If I remember correctly (don't have QTP in front of me) GetItem only  
> takes an index as a parameter. While everything in VBScript is a  
> variant, the implication of an index is an int value.  If you passed  
> in "0", the variant string should be cast to an int 0, but "0;0" would  
> not be cast to a int value, so the complaint that there is an invalid  
> argument would be an appropriate response to the line:
>
>       JavaTree("tree").GetItem("0;0")
>
> Since you already know that but JavaTree("tree").GetItem("0") is  
> valid, I might point out that it would be more correct to write:
>
>       JavaTree("tree").GetItem(0)
>
> However, none of that solves any of your issue.  My initial thought(s)  
> would be
>
> 1) Look at the child items as a collection and loop through the  
> collection, and evaluate each to find the one or more child items you  
> are looking for.
>
> - or -
>
> 2) use a description object to describe the child node that you are  
> looking for and work with it directly.
>
> Mike Pietsch
>
> Quoting Vishal <surivis...@gmail.com>:
>
>
>
>
>
> > Hi
>
> > I am trying to get the text/label of a child node of a javatree but
> > the GetItem method is not working for the child node.
>
> > For example, I have a tree with first node as "Parent1" and it has a
> > child node "Child1"
> > GetItem method is returning only the parent node value.
> > JavaTree("tree").GetItem("0")  gives me "Parent1"
> > but JavaTree("tree").GetItem("0;0") gives an error that the function
> > has invalid arguments.
>
> > I am able to use the select method to select the node using the
> > separator
> > JavaTree("tree").Select "Parent1;Child1"
>
> > Will really appreciate if anyone can provide some help/workaround.
>
> > Thanks
> > Vishal- Hide quoted text -
>
> - Show quoted text -

Siraz Shaik

unread,
Nov 26, 2013, 11:55:36 PM11/26/13
to mercu...@googlegroups.com, QTP - HP Quick Test Professional - Automated Software Testing
Hi Vishal, I am also facing the same issue... Have you resolved the issue ?
if so please share the solution.

Thanks,
siraj

Murali R

unread,
Sep 17, 2014, 7:44:46 AM9/17/14
to mercu...@googlegroups.com, Mercu...@googlegroups.com
Hi Vishal/Siraj,

Please let me know if you have got any solution to this problem, I am also facing the same issue with custom java tree object.

Thanks
Murali LM Rao

Omkar

unread,
Sep 17, 2014, 10:40:37 AM9/17/14
to mercu...@googlegroups.com

Also. If want to pass index use hash #
E.g.getitem(#0:#0)

On 17/09/2014 5:30 pm, "Omkar" <omkar....@gmail.com> wrote:

Please check the operator for java tree in options window ...Is is set to -" ; "?
Try - (parent1:child1)

--
--
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
 
---
You received this message because you are subscribed to the Google Groups "QTP - HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mercuryqtp+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Omkar

unread,
Sep 17, 2014, 10:40:37 AM9/17/14
to mercu...@googlegroups.com

Please check the operator for java tree in options window ...Is is set to -" ; "?
Try - (parent1:child1)

On 27/11/2013 10:27 am, "Siraz Shaik" <shaik...@gmail.com> wrote:
--
Reply all
Reply to author
Forward
0 new messages