如何使用延迟加载为数据表编写xpath以使用selinium

时间:2017-06-01 11:17:48

标签: 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 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>

class

的问候, Apurva

1 个答案:

答案 0 :(得分:0)

计算表格中的行数:

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