Get related column when column/row hierarchy is switched

Class library usage, coding and language questions.
markrussell
Posts: 7
Joined: Thu Jan 24, 2013 12:40 am

Get related column when column/row hierarchy is switched

Post by markrussell » Mon Feb 04, 2013 3:23 am

Hi team,

I'm trying to write code (CSharp) to interrogate a table (Flex) by looking up a particular cell (which I can do successfully) and then return the related values in several adjacent columns - within the same row.

Looking at examples, I can see two ways that one might normally do this: i) use following or preceding sibling or ii) after identifying the matching cell, then simply go up one level to get to the row and then go down again and specify the actual column number.

However this will not work for me, because the table hierarchy is organized such that each column element is directly subordinate to the table and within each column element we have a list of rows (each containing a single cell). Therefore if I go up a level I simply get the column group containing all the cells in the column.

Essentially, it seems that I need to be able to somehow find the index number (rownumber) of the matched element in the column and then using that rownumber, lookup the cell in a different column.

Can this be done and if so, how?

Cheers,
Mark

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Get related column when column/row hierarchy is switched

Post by Support Team » Tue Feb 05, 2013 1:22 pm

Hello Mark,

I'm not sure how your table looks like, but you could use the RxPath to get the "rowindex" property of the current cell.
Example:
var firstCell =  @"/dom[@domain='www.youdomain.com']//table/column[@text='Column1']/cell[@text='YourCell']";
int rowIndex = midWest.RowIndex;
			
Ranorex.Cell secondCell = @"/dom[@domain='www.youdomain.com']//table/column[@text='Column2']/cell[@rowindex='"+ rowIndex.ToString() +"']";
Report.Info(secondCol.Text);
I hope this is what you want to do.

Regards,
Bernhard
.
Image

markrussell
Posts: 7
Joined: Thu Jan 24, 2013 12:40 am

Re: Get related column when column/row hierarchy is switched

Post by markrussell » Thu Feb 14, 2013 8:33 am

Thanks Bernhard,

I actually used ChildIndex from the Element member, but did effectively the same thing as you suggest there.
I suspect RowIndex will only work if you have an actual Cell adapter.

Regards
Mark