简体   繁体   中英

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>

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();

JQuery will be easy.

 let rowCount = $(".srringtable").length; $("input#count").val(rowCount);
 <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script> <table class="table_pay"> <tbody> <div class="srringtable"></div> <div class="srringtable"></div> <div class="srringtable"></div> <div class="srringtable"></div> <div class="srringtable"></div> <div class="srringtable"></div> <div class="srringtable"></div> <div class="srringtable"></div> </tbody> </table> <input id="count">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM