@@ -523,9 +523,15 @@ def _set_firefox_options(
523
523
firefox_arg ,
524
524
firefox_pref ,
525
525
):
526
+ blank_p = "about:blank"
526
527
options = webdriver .FirefoxOptions ()
527
528
options .accept_untrusted_certs = True
528
529
options .set_preference ("reader.parse-on-load.enabled" , False )
530
+ options .set_preference ("browser.startup.homepage" , blank_p )
531
+ options .set_preference ("startup.homepage_welcome_url" , blank_p )
532
+ options .set_preference ("startup.homepage_welcome_url.additional" , blank_p )
533
+ options .set_preference ("trailhead.firstrun.branches" , "nofirstrun-empty" )
534
+ options .set_preference ("browser.aboutwelcome.enabled" , False )
529
535
options .set_preference ("pdfjs.disabled" , True )
530
536
options .set_preference ("app.update.auto" , False )
531
537
options .set_preference ("app.update.enabled" , False )
@@ -1485,60 +1491,45 @@ def get_local_driver(
1485
1491
)
1486
1492
sb_install .main (override = "geckodriver" )
1487
1493
sys .argv = sys_args # Put back original sys args
1488
- warnings .simplefilter ("ignore" , category = DeprecationWarning )
1489
- if "linux" in PLATFORM :
1490
- from selenium .webdriver .common .desired_capabilities import (
1491
- DesiredCapabilities ,
1492
- )
1493
-
1494
- firefox_capabilities = DesiredCapabilities .FIREFOX .copy ()
1495
- firefox_capabilities ["marionette" ] = True
1496
- if headless :
1497
- firefox_capabilities ["moz:firefoxOptions" ] = {
1498
- "args" : ["-headless" ]
1499
- }
1500
- return webdriver .Firefox (
1501
- capabilities = firefox_capabilities , options = firefox_options
1502
- )
1503
- else :
1504
- if os .path .exists (LOCAL_GECKODRIVER ):
1505
- if selenium4 :
1506
- service = FirefoxService (
1507
- executable_path = LOCAL_GECKODRIVER ,
1508
- log_path = os .path .devnull ,
1494
+ # Launch Firefox
1495
+ if os .path .exists (LOCAL_GECKODRIVER ):
1496
+ if selenium4 :
1497
+ service = FirefoxService (
1498
+ executable_path = LOCAL_GECKODRIVER ,
1499
+ log_path = os .path .devnull ,
1500
+ )
1501
+ try :
1502
+ return webdriver .Firefox (
1503
+ service = service ,
1504
+ options = firefox_options ,
1509
1505
)
1510
- try :
1506
+ except Exception as e :
1507
+ if "Process unexpectedly closed" in e .msg :
1508
+ # Firefox probably just auto-updated itself.
1509
+ # Trying again right after that often works.
1511
1510
return webdriver .Firefox (
1512
1511
service = service ,
1513
1512
options = firefox_options ,
1514
1513
)
1515
- except Exception as e :
1516
- if "Process unexpectedly closed" in e .msg :
1517
- # Firefox probably just auto-updated itself.
1518
- # Trying again right after that often works.
1519
- return webdriver .Firefox (
1520
- service = service ,
1521
- options = firefox_options ,
1522
- )
1523
- else :
1524
- raise Exception (e .msg ) # Not an obvious fix.
1525
- else :
1526
- return webdriver .Firefox (
1527
- executable_path = LOCAL_GECKODRIVER ,
1528
- service_log_path = os .path .devnull ,
1529
- options = firefox_options ,
1530
- )
1514
+ else :
1515
+ raise Exception (e .msg ) # Not an obvious fix.
1531
1516
else :
1532
- if selenium4 :
1533
- service = FirefoxService (log_path = os .path .devnull )
1534
- return webdriver .Firefox (
1535
- service = service , options = firefox_options
1536
- )
1537
- else :
1538
- return webdriver .Firefox (
1539
- service_log_path = os .path .devnull ,
1540
- options = firefox_options ,
1541
- )
1517
+ return webdriver .Firefox (
1518
+ executable_path = LOCAL_GECKODRIVER ,
1519
+ service_log_path = os .path .devnull ,
1520
+ options = firefox_options ,
1521
+ )
1522
+ else :
1523
+ if selenium4 :
1524
+ service = FirefoxService (log_path = os .path .devnull )
1525
+ return webdriver .Firefox (
1526
+ service = service , options = firefox_options
1527
+ )
1528
+ else :
1529
+ return webdriver .Firefox (
1530
+ service_log_path = os .path .devnull ,
1531
+ options = firefox_options ,
1532
+ )
1542
1533
elif browser_name == constants .Browser .INTERNET_EXPLORER :
1543
1534
if not IS_WINDOWS :
1544
1535
raise Exception (
0 commit comments