简体   繁体   English

从 web 表中获取行数 -SELENID

[英]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.我正在使用 Selenide,但是,我需要计算表中的行数来编写测试。 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.该表格具有显示行数的功能,我想检查选择时,例如15行,表格中显示15。 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.您可以使用 class “srringtable” 查找所有元素,然后使用 .size() 方法,使用 Selenide 计算表中的行数。

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

JQuery will be easy. JQuery会很容易。

 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">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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