This is a migrated thread and some comments may be shown as answers.

How to count the no of rows in the Html table with many pages

3 Answers 517 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nithya
Top achievements
Rank 1
Veteran
Nithya asked on 29 Jul 2019, 01:28 PM

Hi ,

My Application is developed in Html5. In the Application , there is a html table with many pages. I need to Count the total number of rows present in the table including all pages.. I try With a simple code as mentioned below:

 

r=Pages.xxxx.mytable.AllRows.Count

Messagebox.show("Count of rows is "&r)

 

This Returns only the number of rows present in the first page.. It doesnt Count the other rows from Next page. Could you please help me to Write a code to Count the total number of rows from all the pages..

 

Regards,

Nithya A.

 

3 Answers, 1 is accepted

Sort by
0
Plamen Mitrev
Telerik team
answered on 30 Jul 2019, 11:11 AM
Hi Nithya,

Please allow me to share some details about Test Studio and how it reads the DOM tree. The table that you see in the page has a number of rows that are visible in the browser. The code that you have shared works against "mytable" element and checks all available rows that are loaded in the DOM tree. I assume that the table has paging and this is why some of the rows do not exist in the DOM and are not visible in this page.

Depending on the application and the table that it contains, you can try different approaches, like:
- inspecting the table control for an element that shows the total number of rows (see the bottom right corner of the sample Kendo grid here). Some control expose this information and you should be able to get this value and verify it;
var items = Pages.xxxx.x120Of91Span.TextContent;
Log.WriteLine("items " + items.Substring(10, 2));
- finding all elements with a specific tag, like "tr", in the specific table element and check the number. This approach will only work if all rows are present in the DOM tree of the page;
var tags = Pages.xxxx.mytable.Find.AllByTagName("tr");
Log.WriteLine("all tags " + tags.Count);
- checking calculating the number of rows based on the number of pages and the elements per page. To do that, you need to check the number of rows in a full page and the number of pages. Please keep in mind that the last page might contain less rows than the others.

I hope that the above details will help you with this scenario. If you continue to experience any troubles, please share a sample of the table and share more details.

Regards,
Plamen Mitrev
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Nithya
Top achievements
Rank 1
Veteran
answered on 30 Jul 2019, 12:31 PM

Hi Plamen,

Thanks for Your details:)

I check the sample kendo grid and now I edit some checkboxes and attach how my table looks like..

The table in my Application doesnot show the no of items in the bottom right corner..

Is there any way to Count the total number of rows for this table Attached..?

 

And as per Your last point , to calculate the number of pages and rows… I think it is not possible since the no of rows in the page is not constant.. It keeps changing whenever i do a particular action..

 

Regards,

Nithya A.

 

 

0
Plamen Mitrev
Telerik team
answered on 30 Jul 2019, 01:00 PM
Hello Nithya,

Thank you for sharing more details about the used table and its options. I believe that if you enable the "display the current range of items" option, you will have the range and probably the total number of items in this table. Then you could proceed and get a substring of that text, to see the total number of items. I used the sample code below:
var items = Pages.xxxx.x120Of91Span.TextContent;
Log.WriteLine("items " + items.Substring(10, 2));

In case the above suggestion does not work as expected, for this specific table control, you can try the following steps.
  1. Extract the value for the number of pages (currently it shows 83) as a variable.
  2. In a coded step, gather the number of rows in the first page and set it as a new variable.
  3. Outside of a coded step, record a click on the button that switches to the last page of this table (see scrollToLastPage.png).
  4. Create a new coded step and again check the number of rows for the last page and add to that the number of pages (from the extracted variable in step 1) multiplied by the rows in the first page (extracted in step 2).

I think that both of the above approaches should help you get the total number of rows in this table. Please let me know if that worked.

Regards,
Plamen Mitrev
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Nithya
Top achievements
Rank 1
Veteran
Answers by
Plamen Mitrev
Telerik team
Nithya
Top achievements
Rank 1
Veteran
Share this question
or