cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if item is not available in treeview

SOLVED
Not applicable

How to check if item is not available in treeview

Hi, I am evaluating TestComplete 7 and  I am stuck on getting TestComplete to check if an item exist in treeview.



For Example: I have a treeview with a parent node A and there is a child under A called Test and under Test there is a child item call Item1 & Item2. If I delete Item2 how can I verify that Item2 is no longer in treeview?



I have the following written in Jscript but it does not work.



if ( ! treeview.wItems.Item("A|Test|Item2").Exists)

  Log.Message("Item2 does not exist in treeview")

else

  Log.Message("Item2 does exist in treeview")



Please Help!



Thanks

Kathy
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: RE: How to check if item is not available in treeview

Hi @M-H-Mukit,

 

You can find Yuri's reply from the mentioned topic below.

However, I would like to draw your attention that this topic is very old. TestComplete has been improved significantly since that time. I suggest that you create your own topic here and describe what you would like to achieve. 

 

Yuri's reply:

Hi,

You can use code like this:

function treeItemExists(tree, itemPath)
{
  var items = itemPath.split("|");
  var treeItems = tree.wItems;
  var found = false;
  for(var item in items)
  {
    found = false;
    if(!treeItems) break;
    
    for(var i = 0; i < treeItems.Count; i++)
    {
      if(treeItems.Item(i).Text == items[item])
      {
        found = true;
        treeItems = treeItems.Item(i).Items;
        break;
      }
    }
  }
  
  return found;
}
...
  var tree = // Obtain the tree view
  if(!treeItemExists(tree, "Shipowners|A1|Chemical"))
    Log.Message("Item does not exist in treeview")
  else
    Log.Message("Item exist therefore delete of item was not successful") 
...
---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

3 REPLIES 3
Staff

RE: How to check if item is not available in treeview

Hi Kathy,



See my reply here:

http://www.sqaforums.com/showflat.php?Cat=0&Number=603184&page=0&vc=&PHPSESSID=#Post603184



------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.
Visitor

Re: RE: How to check if item is not available in treeview

Can't open the link. Can you please share again ?

Community Manager

Re: RE: How to check if item is not available in treeview

Hi @M-H-Mukit,

 

You can find Yuri's reply from the mentioned topic below.

However, I would like to draw your attention that this topic is very old. TestComplete has been improved significantly since that time. I suggest that you create your own topic here and describe what you would like to achieve. 

 

Yuri's reply:

Hi,

You can use code like this:

function treeItemExists(tree, itemPath)
{
  var items = itemPath.split("|");
  var treeItems = tree.wItems;
  var found = false;
  for(var item in items)
  {
    found = false;
    if(!treeItems) break;
    
    for(var i = 0; i < treeItems.Count; i++)
    {
      if(treeItems.Item(i).Text == items[item])
      {
        found = true;
        treeItems = treeItems.Item(i).Items;
        break;
      }
    }
  }
  
  return found;
}
...
  var tree = // Obtain the tree view
  if(!treeItemExists(tree, "Shipowners|A1|Chemical"))
    Log.Message("Item does not exist in treeview")
  else
    Log.Message("Item exist therefore delete of item was not successful") 
...
---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

New Here?
Join us and watch the welcome video: