Table 元素断言
Table element assertion
我正在尝试断言 table 上是否显示 11223。
元素如下:
<div class="page-wrapper table-responsive" id="shipping-option" xpath="1">
<table class="table table-bordered">
<tbody>
<tr>
<th></th>
<th class="checkUncheck">
<span title="" data-toggle="tooltip" data-placement="top" data-original-title="Check / Uncheck All">
<input type="checkbox" id="checkAll" class="icheckbox_square-green form-control">
</span>
</th>
<th>
Date/ID
</th>
<th>
Name(pet name)
</th>
<th>
Country/State
</th>
<th>
Designation
</th>
</tr>
<tr class="rowclick" style="cursor:pointer">
<td>
1
</td>
<td class="shipmentCheckbox">
<input class="GroupChb" id="61577" name="item.isSelected" type="checkbox" value="true"><input name="item.isSelected" type="hidden" value="false">
</td>
<td>
06-01-2021
<br>
<a href="http://www.google.dk" target="popup" onclick="window.open('http://www.google.dk'),'popup','width=600,height =600'); return false;">
11223
</a>
</td>
<td>
Jonny
<br>
<span class="sub">
Joe
</span>
</td>
<td>
US <br>
<span class="sub">California</span>
</td>
<td>
Software Quality Analyst
<br>
<span class="sub">
QA
</span>
</td>
</tr>
<tr>
<td colspan="10"></td>
</tr>
</tbody>
</table>
<div>
这是行不通的。我收到以下错误:
-contains tr.rowclick, 11223
Timed out retrying: Expected to find content: '11223' within the
element: <table.table.table-bordered> and with the selector:
'tr.rowclick' but never did. cypress/integration/History.js:55:65 53
|
cy.get('#SearchString').type('11223')
54 | cy.get('#filter').click()
> 55 | cy.get('.page-wrapper').find('.table-bordered').contains('tr.rowclick','11223')
| ^
56 |
57 | })
58 | })
<td>
没有 rowclick class,<tr>
有。
这是我检查“11223”是否在单元格中的首选命令:
cy.contains('tr.rowclick td', '11223')
请注意,搜索了所有 <td>
个子元素(如 <a>
)。
这是我喜欢的一种极简主义方法,因为更改页面结构可能会破坏测试(个人偏好)。
我正在尝试断言 table 上是否显示 11223。
元素如下:
<div class="page-wrapper table-responsive" id="shipping-option" xpath="1">
<table class="table table-bordered">
<tbody>
<tr>
<th></th>
<th class="checkUncheck">
<span title="" data-toggle="tooltip" data-placement="top" data-original-title="Check / Uncheck All">
<input type="checkbox" id="checkAll" class="icheckbox_square-green form-control">
</span>
</th>
<th>
Date/ID
</th>
<th>
Name(pet name)
</th>
<th>
Country/State
</th>
<th>
Designation
</th>
</tr>
<tr class="rowclick" style="cursor:pointer">
<td>
1
</td>
<td class="shipmentCheckbox">
<input class="GroupChb" id="61577" name="item.isSelected" type="checkbox" value="true"><input name="item.isSelected" type="hidden" value="false">
</td>
<td>
06-01-2021
<br>
<a href="http://www.google.dk" target="popup" onclick="window.open('http://www.google.dk'),'popup','width=600,height =600'); return false;">
11223
</a>
</td>
<td>
Jonny
<br>
<span class="sub">
Joe
</span>
</td>
<td>
US <br>
<span class="sub">California</span>
</td>
<td>
Software Quality Analyst
<br>
<span class="sub">
QA
</span>
</td>
</tr>
<tr>
<td colspan="10"></td>
</tr>
</tbody>
</table>
<div>
这是行不通的。我收到以下错误:
-contains tr.rowclick, 11223
Timed out retrying: Expected to find content: '11223' within the element: <table.table.table-bordered> and with the selector: 'tr.rowclick' but never did. cypress/integration/History.js:55:65 53 |
cy.get('#SearchString').type('11223') 54 | cy.get('#filter').click() > 55 | cy.get('.page-wrapper').find('.table-bordered').contains('tr.rowclick','11223') | ^ 56 | 57 | }) 58 | })
<td>
没有 rowclick class,<tr>
有。
这是我检查“11223”是否在单元格中的首选命令:
cy.contains('tr.rowclick td', '11223')
请注意,搜索了所有 <td>
个子元素(如 <a>
)。
这是我喜欢的一种极简主义方法,因为更改页面结构可能会破坏测试(个人偏好)。