Cypress 和 select2 jquery 插件
Cypress and select2 jquery plugin
如何将 cypress 与 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"]')
Object { 0: select#frm-vehicleInsurance-form-client_type.form-control.select2-hidden-accessible, length: 1, prevObject: {...} }
我已经开始制作食谱,现在展示如何 select 单个值(您的用例),请参阅 https://github.com/cypress-io/cypress-example-recipes/pull/439
如何将 cypress 与 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"]')
Object { 0: select#frm-vehicleInsurance-form-client_type.form-control.select2-hidden-accessible, length: 1, prevObject: {...} }
我已经开始制作食谱,现在展示如何 select 单个值(您的用例),请参阅 https://github.com/cypress-io/cypress-example-recipes/pull/439