How to find element and select by cypress.io with vue.js v-select?

你。 提交于 2020-06-14 07:29:35

问题


Sorry,I need help about find element v-select and select option by cypress.io.

<v-select
      label="label"
      v-model="ccRcode"
      ref="ccRcode"
      :items="getData"
      item-text="descWithCode"
      item-value="code"
      value="{ ccRcode }"
      data-test='test'
></v-select>

回答1:


Since you are using Vuetify's select, their documentation should be the first stop. Check the references below.

Basically, they add data-cy data attributes to make it easy to target elements. So in your example:

<v-select
      label="label"
      v-model="ccRcode"
      ref="ccRcode"
      :items="getData"
      item-text="descWithCode"
      item-value="code"
      value="{ ccRcode }"
      data-cy='select-input'
></v-select>

And then in your test:

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

References:

  • https://vuetifyjs.com/en/getting-started/unit-testing#e-2-e-tests
  • https://docs.cypress.io/api/commands/select.html#Syntax



回答2:


Try:

cy.get('[data-test=test]').type('valueNameGoesHere{enter}', {force: true})


来源:https://stackoverflow.com/questions/58298675/how-to-find-element-and-select-by-cypress-io-with-vue-js-v-select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!