Relaxing Chrome#39;s CSP while running tests (webdriver) (Content-Security-policy)(在运行测试时放宽 Chrome 的 CSP (webdriver) (Content-Security-policy))
问题描述
我正在尝试在使用 proctractor(webdriver、chromedriver)运行测试时放松 Chrome 的 CSP.
I'm trying to relax Chrome's CSP while running a test using proctractor (webdriver, chromedriver).
所以解决方案可以是
- 根据我的搜索结果,类似--disable-csp"的标志不存在.
- webdriver/protractor 的设置.
我找不到任何解决方案,只能设置一个过滤标头的代理.
I could not find any solution but to setup a proxy that filters the header.
有什么想法吗?
推荐答案
目前没有原生选项,但您可以使用扩展禁用 CSP.
currently there are no native option but you can disable CSP using extension.
步骤:
- 下载扩展禁用内容安全策略
- 将其保存为
.zip,因为它需要修改以在启动时启用禁用CSP" - 解压文件或使用Winrar双击文件
background.js编辑 - 将
var isCSPDisabled = false;更改为true - 保存更改.
- Download extension Disable Content-Security-Policy
- Save it as
.zip, because it need modification to enable "disable CSP" at start - extract the file or if using Winrar double click file
background.jsto edit - change
var isCSPDisabled = false;totrue - save change.
代码
chrome_options = Options()
chrome_options.add_extension('path/to/disableCSP.zip') # or disableCSP.xpi
driver = webdriver.Chrome(chrome_options=chrome_options)
这篇关于在运行测试时放宽 Chrome 的 CSP (webdriver) (Content-Security-policy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在运行测试时放宽 Chrome 的 CSP (webdriver) (Content-Security-policy)
基础教程推荐
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
