【发布时间】:2019-09-26 12:50:31
【问题描述】:
我目前正在运行 Chrome 74 并尝试使用 Cypress 在我的应用程序中测试样式指南。当我加载赛普拉斯时,它会抛出这个错误:
SecurityError: Blocked a frame with origin "http://localhost:3000" 从访问跨域框架。
如果有解决办法,请告诉我!
我曾试图遵循这一点: 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')
})
【问题讨论】:
标签: google-chrome cypress