首页 > 解决方案 > 在 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 |     })

标签: selectelementcypress

解决方案


OP 能够通过添加来解决这个问题force: true

cy.get('.isChecked').click({ multiple: true, force: true })

推荐阅读