如何在 cypress 中使用 vue-select

How to use vue-select with cypress

在@vue/cli 4.0.5 应用程序中使用 cypress 我遇到了如何填充 vue-select 组件

的问题

在网上搜索我找到了这个 How to find element and select by cypress.io with vue.js v-select? branch,但是这里提出的方法不行。

有组件定义:

<v-select
        v-model="selection_parent_id"
        label="label"
        :options="categoriesLabels"
        id="parent_id"
        name="parent_id"
        class="form-control admin_control_input editable_field"
        placeholder="Select option"
        data-cy='select-input'
></v-select>

我试图在赛普拉斯测试中添加一行:

cy.get('[data-cy=select-input]').select('1')

出现错误:

CypressError: cy.select() can only be called on a <select>. Your subject is a: <div dir="auto" class="v-select form-control admin_control_input editable_field vs--single vs--searchable" id="parent_id" name="parent_id" data-cy="select-input">...</div>
"vue": "^2.6.10",
"vue-select": "^3.2.0",

"@vue/cli-plugin-e2e-cypress": "~4.2.0",
"@vue/cli-plugin-router": "^4.0.0",
"@vue/cli-plugin-vuex": "^4.0.0",
"@vue/cli-service": "^4.0.0",
"bootstrap": "^4.3.1",
"faker": "^4.1.0",
"jquery": "^3.4.1",

有没有有效的方法?

谢谢!

我找到了一个按下键/回车键的决定:

cy.get('#parent_id').click().type('{downarrow}{enter}')

这对我有用!