Relaxing Chrome's CSP while running tests (webdriver) (Content-Security-policy)

本秂侑毒 提交于 2019-12-04 05:23:45

问题


I'm trying to relax Chrome's CSP while running a test using proctractor (webdriver, chromedriver).

So the solution can be either

  1. a flag like "--disable-csp" which dose not exist according to my search results.
  2. a setting for webdriver/protractor to do so.

I could not find any solution but to setup a proxy that filters the header.

any ideas?


回答1:


currently there are no native option but you can disable CSP using extension.

Step:

  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.

code

chrome_options = Options()
chrome_options.add_extension('path/to/disableCSP.zip') # or disableCSP.xpi
driver = webdriver.Chrome(chrome_options=chrome_options)


来源:https://stackoverflow.com/questions/53304222/relaxing-chromes-csp-while-running-tests-webdriver-content-security-policy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!