Get value of row number from specific value

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
ayat
Posts: 16
Joined: Thu May 12, 2016 9:23 pm

Get value of row number from specific value

Post by ayat » Mon Aug 08, 2016 9:55 am

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,

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Get value of row number from specific value

Post by odklizec » Mon Aug 08, 2016 9:58 am

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ayat
Posts: 16
Joined: Thu May 12, 2016 9:23 pm

Re: Get value of row number from specific value

Post by ayat » Mon Aug 08, 2016 10:38 am

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

jma
Posts: 107
Joined: Fri Jul 03, 2015 9:18 am

Re: Get value of row number from specific value

Post by jma » Wed Aug 10, 2016 8:42 am

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.

ayat
Posts: 16
Joined: Thu May 12, 2016 9:23 pm

Re: Get value of row number from specific value

Post by ayat » Wed Aug 10, 2016 9:06 am

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,