Tree interrogation

Ask general questions here.
chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Tree interrogation

Post by chrisgeorge » Fri Aug 21, 2009 9:39 am

We are evaluating Ranorex at the moment for a new project, and it does look rather good at present!

What I do need to do, however, is to interrogate tree items so as to get their icon or icon index at the very least, specifically in Sql Server management studio.

I've tried everything that I can think of but cannot seem to gain access to this. Does anyone have any ideas?

Regards

Chris
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Tree interrogation

Post by Ciege » Fri Aug 21, 2009 4:08 pm

I've not tried specifically on SQL Server Management Studio but here is the process I use to get tree data:

1) Find the tree (using FindSingle)

Code: Select all

Ranorex.Tree RanorexTree = Host.Local.FindSingle(strTreeCostXPath, 30000);
2) Find the correct container I want to interact with (i.e. the data panel)

Code: Select all

HDTreeContainer = RanorexTree.FindSingle(".//container[@accessiblename='" + strTreeContainer + "']", 30000);
3) Get a list of each Tree Item in the continaer and iterate through those Tree Items

Code: Select all

IList<Ranorex.TreeItem> ContainerItems = HDTreeContainer.FindChildren<Ranorex.TreeItem>();
foreach (Ranorex.TreeItem Item in ContainerItems)
4) get a list of each Tree Item cells and interate through those cells

Code: Select all

IList<Ranorex.Cell> TreeItemCells = Item.FindChildren<Ranorex.Cell>();
foreach (Ranorex.Cell Cell in TreeItemCells)
5) You now have access to each cell in the tree that you want to interact with

Code: Select all

string strCell = Cell.ToString();
string strCellText = Cell.Text.ToString();

There is probably a simpler/better way to do this. I wrote this when I was first learning Ranorex and never had the time to go back and make it better, but it serves my purpose for now.

Also, I've left out some of the surrounding code since some of these lines of code are from separate methods and have other reporting information associated with them.

Good luck!
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: Tree interrogation

Post by chrisgeorge » Fri Aug 21, 2009 4:50 pm

Hi, Thanks for your reply.

Unfortunately it doesn't work for me. The SSMS tree view is lazy loaded, so when I look at the Cells IList, it has zero entries. :(

The only way I am able to navigate around the tree is by using the xpaths.

Any other ideas? :-)

Chris
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Tree interrogation

Post by Ciege » Fri Aug 21, 2009 4:59 pm

Try ivoking the expand all function of the tree. My tree is the same. I must expand it so that I can then access it.

Look into using InvokeRemotely from Ranorex to invoke the expand all method of the tree.

Once I know what the TreeList object is, is what I use for my DevExpress Tree Lists:

Code: Select all

(control as DevExpress.XtraTreeList.TreeList).ExpandAll();
After I do the expand all I can then iterate the tree items and get the data that I need.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

chrisgeorge
Posts: 49
Joined: Thu Aug 20, 2009 11:28 am

Re: Tree interrogation

Post by chrisgeorge » Mon Aug 24, 2009 1:20 pm

WOO HOO!! yes, I took the some other example code on the forums (or was it the blog) using InvokeRemotely, and I actually managed to get it to work, returning the Image object :-)

Actually what I did was use my existing tree handlign code to manipulate the tree down to the object that I was interested in; selected it; then ran the invokeremotely stuff to get the image of the "SelectedNode" of the tree.

Thanks!! The evaluation of Ranorex as our GUI tool of choice is going rather well!
Chris George
Test Engineer

Red Gate Software Ltd
Cambridge

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Tree interrogation

Post by Ciege » Mon Aug 24, 2009 4:05 pm

Cool, glad you got it working.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...