如何解决在 Cypress 上执行测试时出错——4050 毫秒后重试超时:coordsHistory 必须至少是 2 组坐标
场景:应选择所有元素。
DOM: (无法发布所有 dom 元素,因为 tehre 是字符限制。所有元素都有类名“isChecked”)
<div class="table-responsive" xpath="1">
<table class="table">
<tbody><tr class="">
<td>
<input class="isChecked" id="listofSalesProducts_0__IsChecked" name="listofSalesProducts[0].IsChecked" type="checkBox" value="true"><input name="listofSalesProducts[0].IsChecked" type="hidden" value="false">
</td>
<td>
4165
</td>
<td>
<input class="noMarkAsreq" data-val="true" data-val-number="The field ID must be a number." id="listofSalesProducts_0__ID" name="listofSalesProducts[0].ID" type="hidden" value="4165">
<label for="listofSalesProducts_0__IsChecked">Element1</label>
</td>
<td>
<div class="is-preferred-wrap details_hide">
<input class="isPreferred" id="listofSalesProducts_0__IsPreferred" name="listofSalesProducts[0].IsPreferred" type="checkBox" value="true"><input name="listofSalesProducts[0].IsPreferred" type="hidden" value="false">
<div class="is-preferred-icon"><i class="fa fa-star" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Preferred"></i><i class="fa fa-star-o" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Click to make Preferred"></i></div>
</div>
</td>
<td>
COURIER
</td>
<td>
Denmark
<div class="details_hide">
<span class="field-validation-valid" data-valmsg-for="listofSalesProducts[0].IsChecked" data-valmsg-replace="true"></span>
<span class="field-validation-valid" data-valmsg-for="listofSalesProducts[0].Name" data-valmsg-replace="true"></span>
</div>
</td>
</tr>
<tr class="">
<td>
<input class="isChecked" id="listofSalesProducts_1__IsChecked" name="listofSalesProducts[1].IsChecked" type="checkBox" value="true"><input name="listofSalesProducts[1].IsChecked" type="hidden" value="false">
</td>
<td>
4166
</td>
<td>
<input class="noMarkAsreq" data-val="true" data-val-number="The field ID must be a number." id="listofSalesProducts_1__ID" name="listofSalesProducts[1].ID" type="hidden" value="4166">
<label for="listofSalesProducts_1__IsChecked">Element2</label>
</td>
<td>
<div class="is-preferred-wrap details_hide">
<input class="isPreferred" id="listofSalesProducts_1__IsPreferred" name="listofSalesProducts[1].IsPreferred" type="checkBox" value="true"><input name="listofSalesProducts[1].IsPreferred" type="hidden" value="false">
<div class="is-preferred-icon"><i class="fa fa-star" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Preferred"></i><i class="fa fa-star-o" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Click to make Preferred"></i></div>
</div>
</td>
<td>
COURIER
</td>
<td>
Denmark
<div class="details_hide">
<span class="field-validation-valid" data-valmsg-for="listofSalesProducts[1].IsChecked" data-valmsg-replace="true"></span>
<span class="field-validation-valid" data-valmsg-for="listofSalesProducts[1].Name" data-valmsg-replace="true"></span>
</div>
</td>
</tr>
<tr class="">
<td>
<input class="isChecked" id="listofSalesProducts_2__IsChecked" name="listofSalesProducts[2].IsChecked" type="checkBox" value="true"><input name="listofSalesProducts[2].IsChecked" type="hidden" value="false">
</td>
<td>
4168
</td>
<td>
<input class="noMarkAsreq" data-val="true" data-val-number="The field ID must be a number." id="listofSalesProducts_2__ID" name="listofSalesProducts[2].ID" type="hidden" value="4168">
<label for="listofSalesProducts_2__IsChecked">Element3</label>
</td>
<td>
<div class="is-preferred-wrap details_hide">
<input class="isPreferred" id="listofSalesProducts_2__IsPreferred" name="listofSalesProducts[2].IsPreferred" type="checkBox" value="true"><input name="listofSalesProducts[2].IsPreferred" type="hidden" value="false">
<div class="is-preferred-icon"><i class="fa fa-star" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Preferred"></i><i class="fa fa-star-o" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Click to make Preferred"></i></div>
</div>
</td>
<td>
COURIER
</td>
<td>
Denmark
<div class="details_hide">
<span class="field-validation-valid" data-valmsg-for="listofSalesProducts[2].IsChecked" data-valmsg-replace="true"></span>
<span class="field-validation-valid" data-valmsg-for="listofSalesProducts[2].Name" data-valmsg-replace="true"></span>
</div>
</td>
</tr>
我使用了上面的代码,检查了 109 个元素中的 32 个。但我需要检查所有元素。 运行上述代码时,我在测试运行器上收到以下错误:
4050ms 后重试超时:coordsHistory 必须至少有 2 组坐标 cypress/integration/StdSysTests/selectproduct_acc.spec.js:28:30
26 | it('Select all products',()=>{
27 |
> 28 | cy.get('.isChecked').click({ multiple: true })
| ^
29 |
30 |
31 | })
解决方法
OP 能够通过添加 force: true
来解决这个问题:
cy.get('.isChecked').click({ multiple: true,force: true })
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。