Java 如何使用selinium为延迟加载的datatable编写xpath以获取总行数

Java 如何使用selinium为延迟加载的datatable编写xpath以获取总行数,java,html,Java,Html,我无法通过延迟加载获取数据表的xpath来计算行数 <div class="dataTables_scrollBody" style="position: relative; overflow: auto; width: 100%; height: 369px; min-height: 0px;"> <table id="offers_table" class="display article-list ranklist_drag table table-bordered da

我无法通过延迟加载获取数据表的xpath来计算行数

<div class="dataTables_scrollBody" style="position: relative; overflow: auto; width: 100%; height: 369px; min-height: 0px;">
<table id="offers_table" class="display article-list ranklist_drag table table-bordered dataTable no-footer" aria-describedby="offers_table_info" role="grid" style="position: absolute; top: 0px; left: 0px; width: 100%;" width="100%" cellspacing="0">
<thead>
<tbody>
<tr class="odd" role="row">
<tr class="even" role="row">
<tr class="odd" role="row">
<tr class="even" role="row">
<tr class="odd" role="row">
<tr class="even" role="row">
<tr class="odd" role="row">
<tr class="even" role="row">
<tr class="odd" role="row">
<tr class="even" role="row">
<tr class="odd" role="row">
<tr class="even" role="row">
<tr class="odd" role="row">
<tr class="even" role="row">
<tr class="odd" role="row">
<tr class="even" role="row">
<tr class="odd" role="row">
<tr class="even" role="row">
<tr class="odd" role="row">
<tr class="even" role="row">
</tbody>
</table>

问候,,
Apurva要计算表中的行数:

driver.findElements(By.cssSelector("#offers_table tbody tr[role='row']")).size()
或xpath:

String xpath = By.xPath("//table[@id='offers_table']//tbody//tr[@role='row']");
driver.findElements(xpath).size()

线程“main”org.openqa.selenium.NoSuchElementException中出现异常:没有此类元素:无法定位元素:{“方法”:“xpath”,“选择器”:”//table[@id='offers_table']//tbody//tr[@role='row']”如果您提供了正确的表id和@role属性,则定位器是正确的)当驱动程序开始查找表时,您确定该表存在于页面上吗?是的,该表存在于同一页面上,但无法定位您确定该表不在iframe中吗?我情不自禁地没有在iframe中看到真正的htmlit