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

Ask general questions here.
NishantSingh
Posts: 39
Joined: Thu Oct 09, 2014 1:15 pm
Location: Bangalore

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

Post by NishantSingh » Mon Dec 08, 2014 9:33 am

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
Regrads,
Nishant Singh

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

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

Post by krstcs » Mon Dec 08, 2014 3:51 pm

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?
Shortcuts usually aren't...

NishantSingh
Posts: 39
Joined: Thu Oct 09, 2014 1:15 pm
Location: Bangalore

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

Post by NishantSingh » Mon Dec 08, 2014 9:07 pm

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
You do not have the required permissions to view the files attached to this post.
Regrads,
Nishant Singh

NishantSingh
Posts: 39
Joined: Thu Oct 09, 2014 1:15 pm
Location: Bangalore

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

Post by NishantSingh » Tue Dec 09, 2014 6:48 am

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
Regrads,
Nishant Singh