如何使用 vue.js v-select 通过 cypress.io 查找元素并选择?

2023-04-21前端开发问题
4

本文介绍了如何使用 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 查找元素并选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

鼠标悬停或悬停 vue.js
Mouseover or hover vue.js(鼠标悬停或悬停 vue.js)...
2023-11-29 前端开发问题
28

是否可以使用 vue-chartjs 打印图表?
Is it possible to print a chart with vue-chartjs?(是否可以使用 vue-chartjs 打印图表?)...
2023-11-02 前端开发问题
4

(Vue, ChartJS) 从子组件画布上下文为图表创建渐变背景
(Vue, ChartJS) Create gradient background for chart from child component canvas context((Vue, ChartJS) 从子组件画布上下文为图表创建渐变背景)...
2023-11-02 前端开发问题
6

vue-chartjs 反应数据错误
vue-chartjs reactive data error(vue-chartjs 反应数据错误)...
2023-11-02 前端开发问题
8

如何在 ChartJS 中创建自定义图例
How to create custom legend in ChartJS(如何在 ChartJS 中创建自定义图例)...
2023-11-01 前端开发问题
1

在 vue 3 中使用 vue-chartjs:createElement 不是函数
using vue-chartjs in vue 3 : createElement is not a function(在 vue 3 中使用 vue-chartjs:createElement 不是函数)...
2023-11-01 前端开发问题
1