gpt4 book ai didi

google-chrome - Cypress 抛出 SecurityError

转载 作者:行者123 更新时间:2023-12-04 18:18:48 27 4
gpt4 key购买 nike

我目前正在使用 Chrome 74 并尝试使用 Cypress 在我的应用程序中测试样式指南。当我加载 Cypress 时,它会抛出这个错误:

SecurityError: Blocked a frame with origin "http://localhost:3000"from accessing a cross-origin frame.


请让我知道是否有解决方案!
我试图跟随这个:
https://github.com/cypress-io/cypress/issues/1951
但没有任何改变/对我有用。 :(
我的代码如下所示: cypress/plugins/index.js
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, args) => {
// browser will look something like this
// {
// name: 'chrome',
// displayName: 'Chrome',
// version: '63.0.3239.108',
// path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
// majorVersion: '63'
// }

if (browser.name === 'chrome') {
args.push('--disable-site-isolation-trials');

return args
}

if (browser.name === 'electron') {
args['fullscreen'] = true

// whatever you return here becomes the new args
return args
}
})
}
在我的 cypress/support/index.js这将在我运行的每个测试之前加载站点,以使自己不必在每个测试中编写 cy.visit。
beforeEach(() =>{
cy.visit('http://localhost:3000/style-guide')
})

最佳答案

我昨天遇到了同样的问题,@jsjoeio 在柏树上的回答 issue #1951您在问题中提到的实际上对我有所帮助。

所以基本上我所做的只是修改我的cypress.json并添加以下值:

{
"chromeWebSecurity": false
}

关于google-chrome - Cypress 抛出 SecurityError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56046632/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com