Search code examples
javaselenide

Getting the count of rows from a web table -SELENID


I am working with Selenide, however, I need to count the number of rows in the table to write tests. The table has the functionality of displaying the number of rows, I want to check that when selecting, for example, 15 rows, 15 is displayed in the table. However, I do not understand exactly how to count them using selenide.

<table class="table_pay">
    <tbody>
        <div class="srringtable">
        <div class="srringtable">
        <div class="srringtable">
        <div class="srringtable">
        <div class="srringtable">
        <div class="srringtable">
        <div class="srringtable">
        <div class="srringtable">
    </tbody>
</table>

Solution

  • You can count the number of rows in the table using Selenide by finding all elements with the class "srringtable" and then using the .size() method.

    int rowCount = $$(".srringtable").size();