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 >
<tbody>
<div >
<div >
<div >
<div >
<div >
<div >
<div >
<div >
</tbody>
</table>
CodePudding user response:
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();
CodePudding user response:
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 >
<tbody>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
</tbody>
</table>
<input id="count">