Verifying an item in Tree : Automation API

Verifying an item in Tree

Class library usage, coding and language questions.

Verifying an item in Tree

Postby Rakesh123 » Sun Jul 10, 2011 4:59 pm

Hi frnds,
I am trying to verify an item is displayed correctly in the Tree object using the following code..

IList<Ranorex.TreeItem> treeitem=Form_Name.TreeOutLine_Name.FindChildren<Ranorex.TreeItem>();

foreach(TreeItem item in treeitem)
{
if(treeitem.text.Contains(item)
{
Report.Success("Item displayed in Tree");
}
else
{
Report.Failure("Item not found");
}
}

But this code is not working.

Below is the way the items are displayed..
-Item1
--Item2
I am trying to verify Item2 in the tree.Pls find the solution ASAP.

Thanks,
Rakesh
Rakesh123
 
Posts: 10
Joined: Thu Oct 28, 2010 3:18 pm

Re: Verifying an item in Tree

Postby Support Team » Mon Jul 11, 2011 11:01 am

Hi,

To me it is not clear what you are trying todo. Do you want to check if a text of a treeitem in your IList contains a specific string? Or do you want to do something else?
Rakesh123 wrote:I am trying to verify an item is displayed correctly in the Tree object using the following code..

The code you posted us cannot work. Is this the exact code you have in your Module? If you compile your code you will get a compiler error, because the IList has no property "Text".

Regards,
Peter
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Verifying an item in Tree

Postby Rakesh123 » Tue Jul 12, 2011 6:58 pm

Yes,I want to verify whether a specific text is displayed as a part of any Treeitem in tree.
Rakesh123
 
Posts: 10
Joined: Thu Oct 28, 2010 3:18 pm

Re: Verifying an item in Tree

Postby Support Team » Wed Jul 13, 2011 11:10 am

Hi,

to check if a tree item ocurs in you tree you can use following method:

public bool findTreeItemInTree(Tree myTree, String itemName)
{
	IList<TreeItem> myItems = myTree.Find<TreeItem>(".//treeitem", 1000);
	foreach (TreeItem myItem in myItems)
	{
		if (myItem.Text == itemName)
			return true;
	}
	return false;
}


For more details about the code, please hava a look at our user guide/api documentation:
http://www.ranorex.com/support/user-gui ... xpath.html
http://www.ranorex.com/Documentation/Ra ... d__1_1.htm
http://www.ranorex.com/blog/ranorexpath-tips-and-tricks

Kind regards,
Tobias
Support Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests

cron