Page 1 of 1

Ranorex table

Posted: Thu May 07, 2015 11:09 pm
by c676228
Hi folks,
I have the following ui.
<table id='usertable'>
<THead id='tableheader'>
<TR><TH>...<TH><TH>...<TH></TR> -- this row is always there no matter there is row presented or not
</THead>
<TBody>
-- dynamica search result will be inserted here.
<TBody>

</table>
in the coding, the intellisense clearly shows that usersTable.Self returns a table. So I have no problem to use intellisense to get to usersTable.Self.Rows.Count.
I wanted to check if usersTable.Self.Rows.Count is equal to 0 or 1 ( not sure the Rows.Count will include THead row or not) to see if there is a search result.
However, the statement is failed. when I check it in the debug mode, The evaluation failed. it says usersTable.Self is no Table.

What am I missing?

Thanks,
Betty

Re: Ranorex table

Posted: Thu May 07, 2015 11:52 pm
by c676228
Well, that's very interesting.
I have to re-map the user table. See attached the screenshot.
Now I have two items with the exactly same xpath. One is pointed to userTable folder. The other is pointed to TableTag under userTable folder.

So now I have repo.website.UsersTable.UsersTable.Children.Count will give me the right row counts of the whole table which includes thead row count.

Lesson learned: 1) Mapping is tricky, especially with web application. Auto recording mappings are not always right, need to double check. However, so far there is no icon legend could be referred from Ranorex site.
2) Ranorex intellisense is probably having a bug

Re: Ranorex table

Posted: Thu May 07, 2015 11:57 pm
by c676228
repo.website.UsersTable.UsersTable.Children.Count is not necessary rows. I assume.
How to get rows in this particular case?

Re: Ranorex table

Posted: Fri May 08, 2015 8:15 am
by CookieMonster
Hi Betty,

Are you talking about TableTag repository item, I have never seen a row property in this tag. Maybe you are accessing a Repository Folder and you are trying to count those rows???

But for your problem, there are several ways to get the count of the row.

One is: IList<TrTag> tableRowTag = ranorexTableTag.FindChildren<TrTag>();
int count = tableRowTag.Count;

Maybe you have to use FindDescendant, depends if the table has TBodyTag.

Or use the XPath, with the Find method.

Regards
Dan

Re: Ranorex table

Posted: Fri May 08, 2015 1:17 pm
by krstcs
As Dan said, a Ranorex Table (for Java/WPF/WinForms tables) is not the same as a Ranorex TableTag (for HTML table tags). They have different methods and properties.

The terms are used interchangeably, but the classes are different.

The tabletag (which is what you are referring to here) does not have a row count property, so you will need to use the method Dan suggested, or something similar.

Re: Ranorex table

Posted: Fri May 08, 2015 8:11 pm
by c676228
Hi Dan/krstcs,

Thanks for the input and info. I use TBodyTag and TrTag class. Now it works for me.
Since TBody tag is always there so I use the row inside this tag to judge if the specified email is found or not.
So time is quick and more controllable than just found the exact email match in the cell of the table(painfully wait for 1.5 min, effective search time out) :D

Re: Ranorex table

Posted: Fri May 08, 2015 9:29 pm
by krstcs
Excellent! Glad it helped!