cypress - Cypress - 使用 Chrome 将函数传递给 .should()
问题描述
Cypress.IO 文档允许将函数传递给 should:https ://docs.cypress.io/api/commands/should.html#Function
如果我在无头或使用电子的情况下运行我的测试但在 Chrome 中失败,因为传递给函数的参数为空,则此方法有效。
我知道该元素存在,因为我之前测试过它。
cypress_runner.js:197677 AssertionError:目标不能为空或未定义。
describe('Cypress ', () => {
it(`Works `, () => {
cy.get('span').should('have.length',25);
cy.get('span').should(($span) => {
expect($span).to.have.length(25);
});
});
})
解决方案
推荐阅读
- c# - 我发布时文件上传控件不起作用
- python - 保存一个文本字符串,如果它由不同的特定文本字符串进行?
- postgresql - 超级用户 nologin 角色?
- sql-server - 使用 head 和 item 表从 ms sql 生成 xml
- extjs - 在 ExtJs 中构建 TreePanel
- python - 在赋值错误python 3之前引用的局部变量
- javascript - React hasOwnProperty 找不到属性
- javascript - 在 ajax 中加载的选择中触发 ajax
- ios - 如何在 App Lovin SDK 中实现原生(矩形)广告?
- c# - 如何使这种方法通用?