因此,在我的应用程序中,我有一个按钮,当我点击它时,它会将一些文本保存到我的剪贴板中,然后我可以通过ctrl+v在某个地方超过它。
我在试着写柏树测试。问题是,当我点击那个按钮时,我得到了柏树错误:

我搞不懂。元素在页面上被清楚地查看。我试着等几秒钟才点击,结果没什么用。
有办法测试吗?
谢谢你的回答。
发布于 2022-02-09 16:42:00
您的应用程序引发了一个错误,而不是cypress。为了避免这种情况,您需要将其添加到测试文件或/support/index.js中。这段代码是从这个示例中提取的。不会的。
// inspect the caught error
cy.on('uncaught:exception', (e) => {
if (e.message.includes('Things went bad')) {
// we expected this error, so let's ignore it
// and let the test continue
return false
}
// on any other error message the test fails
})发布于 2022-02-09 15:37:49
您可以通过在cypress/support/index.js下编写此文件来全局捕获异常。
Cypress.on('uncaught:exception', (err, runnable) => {
return false
})https://stackoverflow.com/questions/71051468
复制相似问题