How to find element and select by cypress.io with vue.js v-select?(如何使用 vue.js v-select 通过 cypress.io 查找元素并选择?)
问题描述
抱歉,我需要有关通过 cypress.io 查找元素 v-select 和选择选项的帮助.
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>
推荐答案
既然你使用的是 Vuetify 的 select,那么第一站应该是他们的文档.检查下面的参考资料.
Since you are using Vuetify's select, their documentation should be the first stop. Check the references below.
基本上,他们添加了 data-cy
数据属性,以便于定位元素.所以在你的例子中:
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>
然后在你的测试中:
cy.get('[data-cy=select-input]').select('optionValue')
参考资料:
- https://vuetifyjs.com/en/getting-started/unit-testing#e-2-e-tests
- https://docs.cypress.io/api/commands/select.html#语法
这篇关于如何使用 vue.js v-select 通过 cypress.io 查找元素并选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 vue.js v-select 通过 cypress.io 查找元素并选择?


基础教程推荐
- fetch 是否支持原生多文件上传? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01