Cypress and select2 jquery插件

问题描述 投票:0回答:1

如何在select2中使用柏树使用Select2 Jquery插件和cypress时遇到一些问题我的html

<div class="form__polozka-hodnota"><select name="client_type" data-cy="typ_klienta" data-dep="" class="form-control"
    id="frm-vehicleInsurance-form-client_type" required
    data-nette-rules='[{"op":":filled","msg":"Vyberte: Typ klienta"}]'>
    <option value="">---</option>
    <option value="1">Fyzická osoba</option>
    <option value="2">Právnická osoba</option>
</select></div>

柏树:

cy.get('[data-cy=typ_klienta]').select('Fyzická osoba').should('have.value', '1')

CypressError:超时重试:cy.select()失败,因为此元素:

...

被另一个元素覆盖:

...

解决此问题,或使用{force:true}禁用错误检查。

https://on.cypress.io/element-cannot-be-interacted-with

输出控制台:

$('[data-cy="typ_klienta"]')

对象{0:select#frm-vehicleInsurance-form-client_type.form-control.select2-hidden-accessible,长度:1,prevObject:{…}}

javascript jquery-select2 cypress
1个回答
0
投票

我已经开始制作食谱,现在显示如何选择一个值(您的用例),请参见https://github.com/cypress-io/cypress-example-recipes/pull/439

© www.soinside.com 2019 - 2024. All rights reserved.