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)
基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
