Page 1 of 1

How to get the column and row number of table using value

Posted: Mon Dec 08, 2014 9:33 am
by NishantSingh
Hi,

just want to how we can get the Table row and column number using the value it contain.

Suppose a table of 3*3. In that cell(2,3) cell text is "Test". So how to find the row number = 2, and Column Number = 3 using the the cell text "Test".

I used cell.Rowindex but its not working returning "0"

please reply

regards,
Nishant Singh

Re: How to get the column and row number of table using value

Posted: Mon Dec 08, 2014 3:51 pm
by krstcs
Please provide more information.

1. What version of Ranorex are you using? This could indicate which methods are available to you.
2. What technology is your system under test developed in? Web, Win32, WPF, Java, etc.


Typically you should be able to use cell.RowIndex and cell.ColumnIndex to get the 0-based index of the Row or Column, respectively, that the cell belongs to.

Are you sure that your use of cell.RowIndex is looking at the correct cell?

Re: How to get the column and row number of table using value

Posted: Mon Dec 08, 2014 9:07 pm
by NishantSingh
Hi,

I am using Ranorex Studio 5.2, OS- Windows 7 and For a windows application created using .net framework.

yes cell.RowIndex is looking at the correct cell because I have used a "foreach" loop to search for a text inside the table and put a "if condition" to break the loop when the text is found.
and inside that "if" block I have used the cell.Rowindex. So basically I am using the cell.RowIndex after the text is found and before the pointer moving to next cell.

I checked with the cell property for Rowindex and ColIndex and these are blank
PFA the table sanpshot.

If you have any solution Please reply


regards,
Nishant Singh

Re: How to get the column and row number of table using value

Posted: Tue Dec 09, 2014 6:48 am
by NishantSingh
Hi,

I have created an alternative solution using that I am able to find the row and col number.

public void getCellValue()
{
Table table = "table Xpath";
table.EnsureVisible();

// Speed up mouse move
Mouse.DefaultMoveTime = 10;
bool endLoop = false;
int intRowNumber=0, intColNumber=0;
foreach (Ranorex.Row row in table.Rows)
{
// Scrolls automatically
// when item is not visible
row.EnsureVisible();
Mouse.Click(row);
intRowNumber = intRowNumber+1;
intColNumber=0;
foreach (Cell cell in row.Cells)
{
//Mouse.Click(cell);
string strCellValue = cell.Element.GetAttributeValueText("AccessibleDescription", new Regex("^Telerik.WinControls.UI.GridViewCellInfo ;(.*?);"));
intColNumber= intColNumber+1;

if (strCellValue == "Text")
{
endLoop = true;

//cell.Children.IndexOf(strCellValue);
Report.Log(ReportLevel.Info,"CellValue",strCellValue);
Report.Log(ReportLevel.Info,"Result","Row Number : " + intRowNumber + " And Column Number : " + intColNumber);
break;
}


}
if (endLoop)
break;
}

}



thanks for your support

Reagrds,
Nishant Singh