Ranorex table

Class library usage, coding and language questions.
c676228
Posts: 176
Joined: Mon Apr 06, 2015 5:40 am

Ranorex table

Post by c676228 » Thu May 07, 2015 11:09 pm

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

c676228
Posts: 176
Joined: Mon Apr 06, 2015 5:40 am

Re: Ranorex table

Post by c676228 » Thu May 07, 2015 11:52 pm

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
Attachments
2015-05-07_UserTableMappingIssue.png
2015-05-07_UserTableMappingIssue.png (13.27 KiB) Viewed 881 times

c676228
Posts: 176
Joined: Mon Apr 06, 2015 5:40 am

Re: Ranorex table

Post by c676228 » Thu May 07, 2015 11:57 pm

repo.website.UsersTable.UsersTable.Children.Count is not necessary rows. I assume.
How to get rows in this particular case?

CookieMonster
Certified Professional
Certified Professional
Posts: 74
Joined: Mon Aug 14, 2006 7:17 pm
Location: CH

Re: Ranorex table

Post by CookieMonster » Fri May 08, 2015 8:15 am

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

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

Re: Ranorex table

Post by krstcs » Fri May 08, 2015 1:17 pm

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

c676228
Posts: 176
Joined: Mon Apr 06, 2015 5:40 am

Re: Ranorex table

Post by c676228 » Fri May 08, 2015 8:11 pm

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

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

Re: Ranorex table

Post by krstcs » Fri May 08, 2015 9:29 pm

Excellent! Glad it helped!
Shortcuts usually aren't...