Hye*_*Eun 2 google-chrome cypress
我目前正在使用Chrome 74运行,并尝试使用赛普拉斯在我的应用中测试样式指南。当我加载赛普拉斯时,它将引发以下错误:
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
}
})
}
Run Code Online (Sandbox Code Playgroud)
在我的 cypress/support/index.js
这将在每次运行测试之前加载该站点,以免于每次测试都必须编写cy.visit。
beforeEach(() =>{
cy.visit('http://localhost:3000/style-guide')
})
Run Code Online (Sandbox Code Playgroud)
小智 11
您可以禁用安全性来解决此问题。
cypress.config.js文件。chromeWebSecurity: false并保存。例如:const { defineConfig } = require('cypress')
module.exports = defineConfig({
...,
chromeWebSecurity: false // add this line
})
Run Code Online (Sandbox Code Playgroud)
昨天我遇到了同样的问题,@ jsjoeio在柏树问题#1951中的答复对您有所帮助。
因此,基本上我唯一要做的就是修改我的代码cypress.json并添加以下值:
{
"chromeWebSecurity": false
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
386 次 |
| 最近记录: |