@@ -516,6 +516,8 @@ def get_local_driver(
516
516
options = webdriver .FirefoxOptions ()
517
517
if headless :
518
518
options .add_argument ('-headless' )
519
+ firefox_capabilities ['moz:firefoxOptions' ] = (
520
+ {'args' : ['-headless' ]})
519
521
if LOCAL_GECKODRIVER and os .path .exists (LOCAL_GECKODRIVER ):
520
522
try :
521
523
make_driver_executable_if_not (LOCAL_GECKODRIVER )
@@ -530,15 +532,20 @@ def get_local_driver(
530
532
" Installing now:" )
531
533
try :
532
534
sb_install .main (override = "geckodriver" )
533
- except Exception :
534
- print ("\n Warning: Could not install geckodriver!" )
535
+ except Exception as e :
536
+ print ("\n Warning: Could not install geckodriver: "
537
+ "%s" % e )
535
538
sys .argv = sys_args # Put back the original sys args
536
- firefox_driver = webdriver .Firefox (
537
- firefox_profile = profile ,
538
- capabilities = firefox_capabilities ,
539
- options = options )
540
- except WebDriverException :
541
- # Skip Firefox options and try again
539
+ if "linux" in PLATFORM or not headless :
540
+ firefox_driver = webdriver .Firefox (
541
+ firefox_profile = profile ,
542
+ capabilities = firefox_capabilities )
543
+ else :
544
+ firefox_driver = webdriver .Firefox (
545
+ firefox_profile = profile ,
546
+ capabilities = firefox_capabilities ,
547
+ options = options )
548
+ except Exception :
542
549
profile = _create_firefox_profile (
543
550
downloads_path , proxy_string , user_agent , disable_csp )
544
551
firefox_capabilities = DesiredCapabilities .FIREFOX .copy ()
0 commit comments