javascript - webdriverio中单个断言中的多个值
问题描述
是否可以将多个可能的值添加到单个期望中?就我而言,标题可能具有不同的文本值,具体取决于网站上的其他进程(下面的代码无法正常工作)。
it('card should have a one of two names', () => {
expect(MyPage.cardName).toHaveText('Good Products' || 'Wonderfull Products');
});
同样的问题也出现在 chai 的身上deep.equal
。一个断言中是否可以有多个变体?
it('should verify the card titles list', () => {
// an array is created here
const cardTitles = MyPage.cardTitlesText();
chaiExpect(cardTitles).to.deep.equal(['Apples', 'Carrots', 'Tomatoes', 'Potatoes'] || ['Potatoes', 'Apples', 'Carrots', 'Tomatoes']);
});
或者也许我错过了测试的整体概念中的一些东西,而这应该首先以不同的方式处理?
解决方案
现在可以在最新版本的内置expect-webdriverio中,只需传递一个字符串数组,见https://webdriver.io/docs/api/expect-webdriverio.html#tohavetext
推荐阅读
- sql - 如何根据 SQL Server 查询中的日期返回下一个后续记录?
- flutter - 如何在颤动中制作响应式容器
- javascript - 在代码中包含客户端 ID 和客户端密码是否存在安全风险?
- python - 关于python中的贪婪正则表达式
- python - Python/pandas - Merge rows of data with same column id
- javascript - 刷新没有 .load 的 div 内容
- javascript - 如何计算平均字符宽度
- python - Python:如何将 unicode 更改为字符串
- tensorflow - 无法使用 SparkNLP 预训练的 T5Transformer,执行器失败并出现错误“图中没有名为 [encoder_input_ids] 的操作”
- javascript - Ant Design 范围选择器 - 我如何禁用未来(下)个月的箭头?