我在我们的团队中使用 Cypress.io 进行端到端测试,但我们经常遇到函数 cy.visit() 的问题。
该网站有许多来自我们服务器的资源(css 文件、js 文件……)和一些外部资源(js 文件)。如果您打开我们的网站,有时会发生外部 js 文件待处理(浏览器正在等待)。
Cypress 在 cy.visit() 执行期间可能正在等待所有资源都加载完毕。这是一个问题。我不需要等待所有资源,因为例如这个外部 js 是用于广告的,它对我们的测试并不重要。
我可以告诉赛普拉斯这样的事情:“在开始加载页面几秒钟后,您可以在没有加载所有资源的情况下执行此测试”?
我试过 onBeforeLoad 与 setTimeout 结合并重新加载,但它失败了:(
cy.visit('https://www.example.org', {
onBeforeLoad: (win) => {
setTimeout(function() {cy.reload(); }, 10000);
}
})
Run Code Online (Sandbox Code Playgroud)
我太疯狂了,我不知道接下来要做什么。请帮助我并为我的英语感到抱歉:) 谢谢!:)
:) I chose for automated testing a tool Cypress.io. I need some tests for my sitemap.xml document and I dont know how to do that :(
I have tried install an npm package libxmljs
npm install libxmljs --save
and load it as plugin in cypress/plugins/index.js
const libxmljs = require('libxmljs');
Run Code Online (Sandbox Code Playgroud)
But there is a problem with this. It shows an error
The plugins file is missing or invalid.
Your pluginsFile is set to /home/my-app/cypress/plugins/index.js, but
either the file is missing,
it …Run Code Online (Sandbox Code Playgroud)