我有一个项目无法利用HTML的水平,并且HTML中的值的大小写不一致。
如果我仅使用小写字符串作为contains()函数的参数,有什么方法可以迫使赛普拉斯匹配文本?
Sri*_*odi 14
Cypress 包含的方法已经具有此类功能。您可以只传递matchCaseas options 参数,cypress 将处理区分大小写/不敏感的条件。下面的代码片段将为您提供帮助。如果您喜欢这个答案,请点赞这个答案并投票。
it('this will pass', () => {
cy.visit('https://example.cypress.io');
cy.contains('commands drive your tests', {matchCase: false})
});
it('this will fail', () => {
cy.visit('https://example.cypress.io');
cy.contains('commands drive your tests', {matchCase: true})
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1789 次 |
| 最近记录: |