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

后端 未结 2 1882
醉话见心
醉话见心 2021-01-16 17:48

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 \"--dis
2条回答
  •  囚心锁ツ
    2021-01-16 18:14

    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)
    

提交回复
热议问题