@@ -94,7 +94,7 @@ def _add_chrome_disable_csp_extension(chrome_options):
94
94
95
95
96
96
def _set_chrome_options (
97
- downloads_path , proxy_string , proxy_auth ,
97
+ downloads_path , headless , proxy_string , proxy_auth ,
98
98
proxy_user , proxy_pass , user_agent ):
99
99
chrome_options = webdriver .ChromeOptions ()
100
100
prefs = {
@@ -119,7 +119,9 @@ def _set_chrome_options(
119
119
chrome_options .add_argument ("--disable-single-click-autofill" )
120
120
chrome_options .add_argument ("--disable-translate" )
121
121
chrome_options .add_argument ("--disable-web-security" )
122
- if settings .DISABLE_CONTENT_SECURITY_POLICY :
122
+ if settings .DISABLE_CONTENT_SECURITY_POLICY and not headless :
123
+ # Headless Chrome doesn't support extensions, which are required
124
+ # for disabling the Content Security Policy on Chrome
123
125
chrome_options = _add_chrome_disable_csp_extension (chrome_options )
124
126
if proxy_string :
125
127
if proxy_auth :
@@ -261,7 +263,7 @@ def get_remote_driver(
261
263
desired_caps = capabilities_parser .get_desired_capabilities (cap_file )
262
264
if browser_name == constants .Browser .GOOGLE_CHROME :
263
265
chrome_options = _set_chrome_options (
264
- downloads_path , proxy_string , proxy_auth ,
266
+ downloads_path , headless , proxy_string , proxy_auth ,
265
267
proxy_user , proxy_pass , user_agent )
266
268
if headless :
267
269
if not proxy_auth :
@@ -472,7 +474,7 @@ def get_local_driver(
472
474
elif browser_name == constants .Browser .GOOGLE_CHROME :
473
475
try :
474
476
chrome_options = _set_chrome_options (
475
- downloads_path , proxy_string , proxy_auth ,
477
+ downloads_path , headless , proxy_string , proxy_auth ,
476
478
proxy_user , proxy_pass , user_agent )
477
479
if headless :
478
480
# Headless Chrome doesn't support extensions, which are
0 commit comments