I\'m trying to relax Chrome\'s CSP while running a test using proctractor (webdriver, chromedriver).
So the solution can be either
currently there are no native option but you can disable CSP using extension.
Step:
.zip
, because it need modification to enable "disable CSP" at startbackground.js
to editvar isCSPDisabled = false;
to true
code
chrome_options = Options()
chrome_options.add_extension('path/to/disableCSP.zip') # or disableCSP.xpi
driver = webdriver.Chrome(chrome_options=chrome_options)
I update @ewwink's answer
var isCSPDisabled = function (tabId) {
return true; // disabledTabIds.includes(tabId);
};
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_extension("/path/to/chrome-csp-disable-master.crx")
driver = webdriver.Chrome(executable_path="/path/to/chromedriver", options=chrome_options)
driver.get("https://www.google.com/")
source: Load chrome extension using selenium