select - 在 Cypress 上执行测试时出错 - 4050 毫秒后重试超时:coordsHistory 必须至少为 2 组坐标
问题描述
场景:应该选择所有元素。
DOM:(无法发布所有 dom 元素,因为有字符限制。所有元素都有类名“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 })
推荐阅读
- ldap - 如何连接到远程 ldap 服务器以从 Windows 10 操作系统执行 ldap 搜索?
- batch-file - 在 CMD/Batch 中提取 TXT 文件的特定部分
- themes - 如何在 Visual Studio 2019(非 VSCODE)上安装主题和语法配色方案?
- excel - 如何删除excel 2013中单元格值的所有格式?
- python - 需要提取 json like 列表的一部分
- go - 在 Go 中获取文件的内容类型时遇到问题
- html - 如何在 IE 中为选择选项设置 css 位置
- c - 问:数组和函数作业
- drools - Drools 对产品目录中的产品进行验证,以确保选择正确的分类
- github - hexo创建的博客在github页面上无效