如何单击柏树在特定文本前面的编辑按钮
我想单击第三列中是否在第三列中找到的编辑按钮(是的,也有botton )
element
I was using below code in test case but didn't work
).contains('yes')。在(()=> { cy.get('。btn.btn-xs.btn-edit')。click() })) 或
`cy.get(':nth-child(6)')。包含('yes')。查找(button).eq(1).click()
html表结构
<tr role="row" class="even">
<td class="sorting_1">
<a href="http://192.168.0.1:8080/details">abc</a>
</td>
<td>xyz</td>
<td>aws</td>
<td>No</td>
<td>No</td>
<td>"Yes"
<button data-role="remove" id="support_22_abc" class="btn btn-rejecttxt" onclick="deletevm(this,'3','3:5659','22','abc','22_abc','284')"><i class="fa fa-times-circle" data-original-title="Remove Mapping" data-toggle="tooltip"></i></button></td>
<td>No</td>
<td>
<div class="btn-group">
<a href="http://192.168.0.1:8080/edit">
<button class="btn btn-xs btn-edit">
<i class="fa fa-pencil" data-original-title="Edit/Update row data" data-toggle="tooltip" data-placement="top"></i></button></a>
</div></td></tr>
I was using below code in test case but didn't work
`cy.get(':nth-child(6)').contains('Yes').within(() => {
cy.get('.btn.btn-xs.btn-edit').click()
})
or
`cy.get(':nth-child(6)').contains('Yes').find(button).eq(1).click()
HTML Table Structure
<tr role="row" class="even">
<td class="sorting_1">
<a href="http://192.168.0.1:8080/details">abc</a>
</td>
<td>xyz</td>
<td>aws</td>
<td>No</td>
<td>No</td>
<td>"Yes"
<button data-role="remove" id="support_22_abc" class="btn btn-rejecttxt" onclick="deletevm(this,'3','3:5659','22','abc','22_abc','284')"><i class="fa fa-times-circle" data-original-title="Remove Mapping" data-toggle="tooltip"></i></button></td>
<td>No</td>
<td>
<div class="btn-group">
<a href="http://192.168.0.1:8080/edit">
<button class="btn btn-xs btn-edit">
<i class="fa fa-pencil" data-original-title="Edit/Update row data" data-toggle="tooltip" data-placement="top"></i></button></a>
</div></td></tr>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我正确阅读它,则需要第三
&lt; td&gt;
带有“是”的。不确定什么
:nth-child(6)
正在选择,但请尝试If I'm reading it correctly, you want the 3rd
<td>
after the one with "Yes ".Not sure what
:nth-child(6)
is selecting, but try this假设
.btn.btn-xs.btn-edit
是编辑按钮的正确选择器。您可以直接使用eq
命令单击第三行上的编辑按钮。根据可用信息,我想到了。在这里,我们首先浏览所有
tr
,然后在中使用我们正在范围内范围内范围内的下一个命令。现在,使用eq(5),我们正在搜索
是
按钮,如果我们找到了它,则单击“编辑”按钮。Assuming
.btn.btn-xs.btn-edit
is the correct selector for edit button. You can directly use theeq
command to click the edit button on the third row.Based on the available info, I came up with this. Here we are looping through the all the
tr
first and then usingwithin
we are scoping the next commands inside the same tr. Now using eq(5) we are searching for theYes
button, and if we found the it, then we click the Edit button.