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
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));
var tags = Pages.xxxx.mytable.Find.AllByTagName("tr");
Log.WriteLine("all tags " + tags.Count);
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
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.
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.
- Extract the value for the number of pages (currently it shows 83) as a variable.
- In a coded step, gather the number of rows in the first page and set it as a new variable.
- Outside of a coded step, record a click on the button that switches to the last page of this table (see scrollToLastPage.png).
- 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