Page 1 of 1

Get value of row number from specific value

Posted: Mon Aug 08, 2016 9:55 am
by ayat
Hi,

I want to recover the row number from a specific value and use that variable in a repository item.


I used this source code with action get value :


IList<Ranorex.Cell> AllCells = repo.Myapp.Form7854852.TableDg.FindDescendants<Ranorex.Cell>();
foreach (Ranorex.Cell ThisCell in AllCells )
{
if (ThisCell.Text == repo.titre)
{
repo.rownumber=ThisCell.RowIndex.ToString();

}
}


Thank you,

Re: Get value of row number from specific value

Posted: Mon Aug 08, 2016 9:58 am
by odklizec
Hi,

Please post a Ranorex snapshot (not screenshot!) of the problematic element. It's hard to suggest something reliable without snapshot or working sample app.

Re: Get value of row number from specific value

Posted: Mon Aug 08, 2016 10:38 am
by ayat
Hi,

I have attached the snapshot of the problem.
In fact, I have a datagrid and I try to find row number from an expression.
The expression is a variable and i want to use the row number as variable in a repository item.

Thank you,

Re: Get value of row number from specific value

Posted: Wed Aug 10, 2016 8:42 am
by jma
Hi ayat,

Basically, the above-mentioned code seems to be okay. I would suggest debugging the code or adding additional log information.

I assume that the condition is never true and therefore the value is not assigned to the repository variable. Please log the value of repo.titre to the report. Probably this variable doesn't contain the correct value.

But first of all I would suggest debugging if any element is found at all. For example, you could set a breakpoint after searching the elements and check if the AllCells object contains any Cell elements.

Re: Get value of row number from specific value

Posted: Wed Aug 10, 2016 9:06 am
by ayat
Hi jma,

Thank you for your reply.
I'll debug as you have advised me.
Otherwise, a colleague advised me to use the Parent operator (../) in the XPath to recognize the element and it work very well.


Thank you very much,