在运行测试时放宽Chrome的CSP(Webdriver)(Content-Security-policy) [英] Relaxing Chrome'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这样的标记根据我的搜索结果不存在。
- 设置Web驱动程序/量角器可以这样做。
我找不到任何解决方案,但要设置代理来过滤标头。
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.
步骤:
- 下载扩展名停用Content-Security-Policy
- 保存称为
.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.js
to 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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文