在运行测试时放宽Chrome的CSP(Webdriver)(Content-Security-policy) [英] Relaxing Chrome's CSP while running tests (webdriver) (Content-Security-policy)

查看:156
本文介绍了在运行测试时放宽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).

因此解决方案可以是


  1. 像 --disable-csp这样的标记根据我的搜索结果不存在。

  2. 设置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.

步骤:


  1. 下载扩展名停用Content-Security-Policy

  2. 保存称为 .zip ,因为它需要修改才能在开始时启用禁用CSP

  3. 提取文件或使用Winrar双击文件 background.js 进行编辑

  4. 更改 var isCSPDisabled = false; true

  5. 保存更改。

  1. Download extension Disable Content-Security-Policy
  2. Save it as .zip, because it need modification to enable "disable CSP" at start
  3. extract the file or if using Winrar double click file background.js to edit
  4. change var isCSPDisabled = false; to true
  5. 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆