cypress - 赛普拉斯 - 根据值使用自定义命令
问题描述
我需要编写一个自定义命令来根据通过 spec.ts 文件提供的元素值执行某些步骤。我无法弄清楚如何将值 A 和 B 传递给自定义命令,如何根据 A 或 B 存储定位器值,然后使用 then 命令打印值
Spec.ts 文件
cy.writetemp(A)
cy.writetemp(B)
自定义命令
cypress.command.add(writetemp,(A) => {
cy.get("select[name='Type']").should('have.value', 'A'), then print Apple
cy.get("select[name='Type']").should('have.value', 'B'), then print Banana
解决方案
我想基于定位器构建逻辑,但意识到这是处理它的不好方法。我切换到属性值并且它起作用了。感谢大家的时间。
推荐阅读
- javascript - 如何以函数式 JS 方式用 Ramda 实现 LoDash 的 sampleSize?
- c++ - 未找到体系结构 x86_64 链接器问题的符号
- html - 伪元素对齐问题
- django - AttributeError - 'DeferredAttribute' 对象没有属性 'all'
- python - UNICODE 规范化的韩文在 Tkinter 上没有正确显示
- scala - Map.keys 和 Map.values 是否以相同的顺序给出并行的元素序列?
- python - 根据索引的 1D 张量从 3D 张量中选择列(Tensorflow)
- excel - 在 VBA Excel 的 ListBox 中搜索 2 个条件
- react-native - React Native Navigation with Redux,如何使用?
- selenium - 使用 selenium chrome 驱动程序在 chrome 信息栏上显示自定义消息