1
votes

Using cypress in @vue/cli 4.0.5 app I faced a problem how to fill vue-select component

Searching in net I found this How to find element and select by cypress.io with vue.js v-select? branch, but the way proposed here does not work.

Having component defind :

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

I tried to add line in cypress test :

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

and got error :

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

Is there is a valid way ?

Thanks!

1

1 Answers

1
votes

I found a dicision with key down / enter keys sent :

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

That works for me!