【问题标题】:How to use vue-select with cypress如何在 cypress 中使用 vue-select
【发布时间】:2020-04-01 06:21:32
【问题描述】:

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

在网上搜索我发现了这个 How to find element and select by cypress.io with vue.js v-select? 分支,但是这里提出的方式行不通。

定义组件:

<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>

我尝试在 cypress 测试中添加行:

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",

有没有有效的方法?

谢谢!

【问题讨论】:

    标签: vuejs2 cypress vue-select


    【解决方案1】:

    我找到了一个发送键按下/输入键的决定:

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

    这对我有用!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-29
      • 1970-01-01
      • 2020-09-04
      • 2020-12-02
      • 1970-01-01
      • 2019-10-31
      • 1970-01-01
      • 2020-01-13
      相关资源
      最近更新 更多