@@ -505,6 +505,8 @@ def _set_chrome_options(
505
505
"--disable-blink-features=AutomationControlled"
506
506
)
507
507
chrome_options .add_experimental_option ("useAutomationExtension" , False )
508
+ if headless :
509
+ chrome_options .add_argument ("--headless" )
508
510
if (settings .DISABLE_CSP_ON_CHROME or disable_csp ) and not headless :
509
511
# Headless Chrome does not support extensions, which are required
510
512
# for disabling the Content Security Policy on Chrome.
@@ -556,16 +558,6 @@ def _set_chrome_options(
556
558
chrome_options , None , proxy_user , proxy_pass , zip_it
557
559
)
558
560
chrome_options .add_argument ("--proxy-pac-url=%s" % proxy_pac_url )
559
- if headless :
560
- if not proxy_auth and not browser_name == constants .Browser .OPERA :
561
- # Headless Chrome doesn't support extensions, which are
562
- # required when using a proxy server that has authentication.
563
- # Instead, base_case.py will use PyVirtualDisplay when not
564
- # using Chrome's built-in headless mode. See link for details:
565
- # https://bugs.chromium.org/p/chromium/issues/detail?id=706008
566
- # Also, Opera Chromium doesn't support headless mode:
567
- # https://github.com/operasoftware/operachromiumdriver/issues/62
568
- chrome_options .add_argument ("--headless" )
569
561
if browser_name != constants .Browser .OPERA :
570
562
# Opera Chromium doesn't support these switches
571
563
chrome_options .add_argument ("--ignore-certificate-errors" )
@@ -951,6 +943,20 @@ def get_driver(
951
943
raise Exception ('The proxy PAC URL must end with ".pac"!' )
952
944
if proxy_pac_url and proxy_user and proxy_pass :
953
945
proxy_auth = True
946
+ if (
947
+ headless
948
+ and proxy_auth
949
+ and (
950
+ browser_name == constants .Browser .GOOGLE_CHROME
951
+ or browser_name == constants .Browser .EDGE
952
+ )
953
+ ):
954
+ # Headless Chrome/Edge doesn't support extensions, which are
955
+ # required when using a proxy server that has authentication.
956
+ # Instead, base_case.py will use the SBVirtualDisplay when not
957
+ # using Chrome's built-in headless mode. See link for details:
958
+ # https://bugs.chromium.org/p/chromium/issues/detail?id=706008
959
+ headless = False
954
960
if (
955
961
browser_name == constants .Browser .GOOGLE_CHROME
956
962
and user_data_dir
@@ -2148,6 +2154,9 @@ def get_local_driver(
2148
2154
"\n Warning: Could not make operadriver"
2149
2155
" executable: %s" % e
2150
2156
)
2157
+ # Opera Chromium doesn't support headless mode.
2158
+ # https://github.com/operasoftware/operachromiumdriver/issues/62
2159
+ headless = False
2151
2160
opera_options = _set_chrome_options (
2152
2161
browser_name ,
2153
2162
downloads_path ,
@@ -2192,6 +2201,7 @@ def get_local_driver(
2192
2201
warnings .simplefilter ("ignore" , category = DeprecationWarning )
2193
2202
return webdriver .Opera (options = opera_options )
2194
2203
except Exception :
2204
+ # Opera support was dropped! Downgrade to Python 3.6 to use it!
2195
2205
return webdriver .Opera ()
2196
2206
elif browser_name == constants .Browser .PHANTOM_JS :
2197
2207
if selenium4_or_newer :
0 commit comments