@@ -129,7 +129,7 @@ def _add_chrome_disable_csp_extension(chrome_options):
129
129
130
130
131
131
def _set_chrome_options (
132
- downloads_path , headless ,
132
+ browser_name , downloads_path , headless ,
133
133
proxy_string , proxy_auth , proxy_user , proxy_pass ,
134
134
user_agent , disable_csp , enable_sync , use_auto_ext ,
135
135
no_sandbox , disable_gpu , incognito , guest_mode , devtools , swiftshader ,
@@ -156,7 +156,20 @@ def _set_chrome_options(
156
156
else :
157
157
chrome_options .add_experimental_option (
158
158
"excludeSwitches" ,
159
- ["enable-automation" , "enable-logging" ])
159
+ ["enable-automation" , "enable-logging" , "enable-blink-features" ])
160
+ if browser_name == constants .Browser .OPERA :
161
+ # Disable the Blink features
162
+ if enable_sync :
163
+ chrome_options .add_experimental_option (
164
+ "excludeSwitches" ,
165
+ (["enable-automation" , "enable-logging" , "disable-sync" ,
166
+ "enable-blink-features" ]))
167
+ chrome_options .add_argument ("--enable-sync" )
168
+ else :
169
+ chrome_options .add_experimental_option (
170
+ "excludeSwitches" ,
171
+ (["enable-automation" , "enable-logging" ,
172
+ "enable-blink-features" ]))
160
173
if mobile_emulator :
161
174
emulator_settings = {}
162
175
device_metrics = {}
@@ -207,7 +220,6 @@ def _set_chrome_options(
207
220
chrome_options .add_argument ("--test-type" )
208
221
chrome_options .add_argument ("--log-level=3" )
209
222
chrome_options .add_argument ("--no-first-run" )
210
- chrome_options .add_argument ("--ignore-certificate-errors" )
211
223
if devtools and not headless :
212
224
chrome_options .add_argument ("--auto-open-devtools-for-tabs" )
213
225
chrome_options .add_argument ("--allow-file-access-from-files" )
@@ -219,7 +231,6 @@ def _set_chrome_options(
219
231
chrome_options .add_argument ("--disable-save-password-bubble" )
220
232
chrome_options .add_argument ("--disable-single-click-autofill" )
221
233
chrome_options .add_argument ("--disable-translate" )
222
- chrome_options .add_argument ("--disable-web-security" )
223
234
chrome_options .add_argument ("--homepage=about:blank" )
224
235
chrome_options .add_argument ("--dns-prefetch-disable" )
225
236
chrome_options .add_argument ("--dom-automation" )
@@ -231,21 +242,30 @@ def _set_chrome_options(
231
242
# Headless Chrome doesn't support extensions, which are required
232
243
# for disabling the Content Security Policy on Chrome
233
244
chrome_options = _add_chrome_disable_csp_extension (chrome_options )
245
+ chrome_options .add_argument ("--enable-sync" )
234
246
if proxy_string :
235
247
if proxy_auth :
236
248
chrome_options = _add_chrome_proxy_extension (
237
249
chrome_options , proxy_string , proxy_user , proxy_pass )
238
250
chrome_options .add_argument ('--proxy-server=%s' % proxy_string )
239
251
if headless :
240
- if not proxy_auth :
252
+ if not proxy_auth and not browser_name == constants . Browser . OPERA :
241
253
# Headless Chrome doesn't support extensions, which are
242
254
# required when using a proxy server that has authentication.
243
255
# Instead, base_case.py will use PyVirtualDisplay when not
244
256
# using Chrome's built-in headless mode. See link for details:
245
257
# https://bugs.chromium.org/p/chromium/issues/detail?id=706008
258
+ # Also, Opera Chromium doesn't support headless mode:
259
+ # https://github.com/operasoftware/operachromiumdriver/issues/62
246
260
chrome_options .add_argument ("--headless" )
247
- # if (headless and "linux" in PLATFORM) or no_sandbox:
248
- chrome_options .add_argument ("--no-sandbox" ) # (Now always on)
261
+ if browser_name != constants .Browser .OPERA :
262
+ # Opera Chromium doesn't support these switches
263
+ chrome_options .add_argument ("--ignore-certificate-errors" )
264
+ chrome_options .add_argument ("--disable-web-security" )
265
+ chrome_options .add_argument ("--no-sandbox" )
266
+ else :
267
+ # Opera Chromium only!
268
+ chrome_options .add_argument ("--allow-elevated-browser" )
249
269
if swiftshader :
250
270
chrome_options .add_argument ("--use-gl=swiftshader" )
251
271
else :
@@ -460,7 +480,7 @@ def get_remote_driver(
460
480
desired_caps ["name" ] = test_id
461
481
if browser_name == constants .Browser .GOOGLE_CHROME :
462
482
chrome_options = _set_chrome_options (
463
- downloads_path , headless ,
483
+ browser_name , downloads_path , headless ,
464
484
proxy_string , proxy_auth , proxy_user , proxy_pass , user_agent ,
465
485
disable_csp , enable_sync , use_auto_ext , no_sandbox , disable_gpu ,
466
486
incognito , guest_mode , devtools , swiftshader , block_images ,
@@ -674,7 +694,7 @@ def get_local_driver(
674
694
elif browser_name == constants .Browser .EDGE :
675
695
try :
676
696
chrome_options = _set_chrome_options (
677
- downloads_path , headless ,
697
+ browser_name , downloads_path , headless ,
678
698
proxy_string , proxy_auth , proxy_user , proxy_pass , user_agent ,
679
699
disable_csp , enable_sync , use_auto_ext ,
680
700
no_sandbox , disable_gpu , incognito , guest_mode , devtools ,
@@ -792,13 +812,25 @@ def get_local_driver(
792
812
safari_capabilities = _set_safari_capabilities ()
793
813
return webdriver .Safari (desired_capabilities = safari_capabilities )
794
814
elif browser_name == constants .Browser .OPERA :
795
- if LOCAL_OPERADRIVER and os .path .exists (LOCAL_OPERADRIVER ):
796
- try :
797
- make_driver_executable_if_not (LOCAL_OPERADRIVER )
798
- except Exception as e :
799
- logging .debug ("\n Warning: Could not make operadriver"
800
- " executable: %s" % e )
801
- return webdriver .Opera ()
815
+ try :
816
+ if LOCAL_OPERADRIVER and os .path .exists (LOCAL_OPERADRIVER ):
817
+ try :
818
+ make_driver_executable_if_not (LOCAL_OPERADRIVER )
819
+ except Exception as e :
820
+ logging .debug ("\n Warning: Could not make operadriver"
821
+ " executable: %s" % e )
822
+ opera_options = _set_chrome_options (
823
+ browser_name , downloads_path , headless ,
824
+ proxy_string , proxy_auth , proxy_user , proxy_pass , user_agent ,
825
+ disable_csp , enable_sync , use_auto_ext ,
826
+ no_sandbox , disable_gpu , incognito , guest_mode , devtools ,
827
+ swiftshader , block_images , user_data_dir , extension_zip ,
828
+ extension_dir , servername , mobile_emulator ,
829
+ device_width , device_height , device_pixel_ratio )
830
+ opera_options .headless = False # No support for headless Opera
831
+ return webdriver .Opera (options = opera_options )
832
+ except Exception :
833
+ return webdriver .Opera ()
802
834
elif browser_name == constants .Browser .PHANTOM_JS :
803
835
with warnings .catch_warnings ():
804
836
# Ignore "PhantomJS has been deprecated" UserWarning
@@ -807,7 +839,7 @@ def get_local_driver(
807
839
elif browser_name == constants .Browser .GOOGLE_CHROME :
808
840
try :
809
841
chrome_options = _set_chrome_options (
810
- downloads_path , headless ,
842
+ browser_name , downloads_path , headless ,
811
843
proxy_string , proxy_auth , proxy_user , proxy_pass , user_agent ,
812
844
disable_csp , enable_sync , use_auto_ext ,
813
845
no_sandbox , disable_gpu , incognito , guest_mode , devtools ,
0 commit comments