@@ -533,6 +533,7 @@ def _set_firefox_options(
533
533
options .set_preference ("browser.startup.homepage" , blank_p )
534
534
options .set_preference ("startup.homepage_welcome_url" , blank_p )
535
535
options .set_preference ("startup.homepage_welcome_url.additional" , blank_p )
536
+ options .set_preference ("browser.newtab.url" , blank_p )
536
537
options .set_preference ("trailhead.firstrun.branches" , "nofirstrun-empty" )
537
538
options .set_preference ("browser.aboutwelcome.enabled" , False )
538
539
options .set_preference ("pdfjs.disabled" , True )
@@ -551,7 +552,11 @@ def _set_firefox_options(
551
552
options .set_preference ("datareporting.healthreport.service.enabled" , False )
552
553
options .set_preference ("datareporting.healthreport.uploadEnabled" , False )
553
554
options .set_preference ("datareporting.policy.dataSubmissionEnabled" , False )
555
+ options .set_preference ("browser.search.update" , False )
556
+ options .set_preference ("privacy.trackingprotection.enabled" , False )
557
+ options .set_preference ("toolkit.telemetry.enabled" , False )
554
558
options .set_preference ("toolkit.telemetry.unified" , False )
559
+ options .set_preference ("toolkit.telemetry.archive.enabled" , False )
555
560
if proxy_string :
556
561
socks_proxy = False
557
562
socks_ver = 0
@@ -588,6 +593,7 @@ def _set_firefox_options(
588
593
options .set_preference (
589
594
"security.mixed_content.block_active_content" , False
590
595
)
596
+ options .set_preference ("security.warn_submit_insecure" , False )
591
597
if settings .DISABLE_CSP_ON_FIREFOX or disable_csp :
592
598
options .set_preference ("security.csp.enable" , False )
593
599
options .set_preference (
@@ -1503,18 +1509,23 @@ def get_local_driver(
1503
1509
if selenium4 :
1504
1510
service = FirefoxService (
1505
1511
executable_path = LOCAL_GECKODRIVER ,
1506
- log_path = os .path . devnull ,
1512
+ log_path = os .devnull ,
1507
1513
)
1508
1514
try :
1509
1515
return webdriver .Firefox (
1510
1516
service = service ,
1511
1517
options = firefox_options ,
1512
1518
)
1513
- except Exception as e :
1519
+ except BaseException as e :
1514
1520
if (
1515
- "Process unexpectedly closed" in e .msg
1516
- or "Failed to read marionette port" in e .msg
1517
- or "A connection attempt failed" in e .msg
1521
+ "Process unexpectedly closed" in str (e )
1522
+ or "Failed to read marionette port" in str (e )
1523
+ or "A connection attempt failed" in str (e )
1524
+ or hasattr (e , "msg" ) and (
1525
+ "Process unexpectedly closed" in e .msg
1526
+ or "Failed to read marionette port" in e .msg
1527
+ or "A connection attempt failed" in e .msg
1528
+ )
1518
1529
):
1519
1530
# Firefox probably just auto-updated itself.
1520
1531
# Trying again right after that often works.
@@ -1523,25 +1534,30 @@ def get_local_driver(
1523
1534
options = firefox_options ,
1524
1535
)
1525
1536
else :
1526
- raise Exception ( e . msg ) # Not an obvious fix.
1537
+ raise # Not an obvious fix.
1527
1538
else :
1528
1539
return webdriver .Firefox (
1529
1540
executable_path = LOCAL_GECKODRIVER ,
1530
- service_log_path = os .path . devnull ,
1541
+ service_log_path = os .devnull ,
1531
1542
options = firefox_options ,
1532
1543
)
1533
1544
else :
1534
1545
if selenium4 :
1535
- service = FirefoxService (log_path = os .path . devnull )
1546
+ service = FirefoxService (log_path = os .devnull )
1536
1547
try :
1537
1548
return webdriver .Firefox (
1538
1549
service = service , options = firefox_options
1539
1550
)
1540
- except Exception as e :
1551
+ except BaseException as e :
1541
1552
if (
1542
- "Process unexpectedly closed" in e .msg
1543
- or "Failed to read marionette port" in e .msg
1544
- or "A connection attempt failed" in e .msg
1553
+ "Process unexpectedly closed" in str (e )
1554
+ or "Failed to read marionette port" in str (e )
1555
+ or "A connection attempt failed" in str (e )
1556
+ or hasattr (e , "msg" ) and (
1557
+ "Process unexpectedly closed" in e .msg
1558
+ or "Failed to read marionette port" in e .msg
1559
+ or "A connection attempt failed" in e .msg
1560
+ )
1545
1561
):
1546
1562
# Firefox probably just auto-updated itself.
1547
1563
# Trying again right after that often works.
@@ -1550,10 +1566,10 @@ def get_local_driver(
1550
1566
options = firefox_options ,
1551
1567
)
1552
1568
else :
1553
- raise Exception ( e . msg ) # Not an obvious fix.
1569
+ raise # Not an obvious fix.
1554
1570
else :
1555
1571
return webdriver .Firefox (
1556
- service_log_path = os .path . devnull ,
1572
+ service_log_path = os .devnull ,
1557
1573
options = firefox_options ,
1558
1574
)
1559
1575
elif browser_name == constants .Browser .INTERNET_EXPLORER :
@@ -1820,7 +1836,7 @@ def get_local_driver(
1820
1836
if selenium4 :
1821
1837
try :
1822
1838
service = EdgeService (
1823
- executable_path = LOCAL_EDGEDRIVER , log_path = os .path . devnull
1839
+ executable_path = LOCAL_EDGEDRIVER , log_path = os .devnull
1824
1840
)
1825
1841
driver = Edge (service = service , options = edge_options )
1826
1842
except Exception as e :
@@ -1840,13 +1856,13 @@ def get_local_driver(
1840
1856
elif "DevToolsActivePort file doesn't exist" in e .msg :
1841
1857
service = EdgeService (
1842
1858
executable_path = LOCAL_EDGEDRIVER ,
1843
- log_path = os .path . devnull ,
1859
+ log_path = os .devnull ,
1844
1860
)
1845
1861
# https://stackoverflow.com/a/56638103/7058266
1846
1862
edge_options .add_argument ("--remote-debugging-port=9222" )
1847
1863
return Edge (service = service , options = edge_options )
1848
1864
if not auto_upgrade_edgedriver :
1849
- raise Exception ( e . msg ) # Not an obvious fix. Raise .
1865
+ raise # Not an obvious fix.
1850
1866
else :
1851
1867
pass # Try upgrading EdgeDriver to match Edge.
1852
1868
args = " " .join (sys .argv )
@@ -1865,7 +1881,7 @@ def get_local_driver(
1865
1881
_repair_edgedriver (edge_version )
1866
1882
_mark_driver_repaired ()
1867
1883
service = EdgeService (
1868
- executable_path = LOCAL_EDGEDRIVER , log_path = os .path . devnull
1884
+ executable_path = LOCAL_EDGEDRIVER , log_path = os .devnull
1869
1885
)
1870
1886
driver = Edge (service = service , options = edge_options )
1871
1887
return driver
@@ -1875,7 +1891,7 @@ def get_local_driver(
1875
1891
try :
1876
1892
driver = Edge (
1877
1893
executable_path = LOCAL_EDGEDRIVER ,
1878
- service_log_path = os .path . devnull ,
1894
+ service_log_path = os .devnull ,
1879
1895
capabilities = capabilities ,
1880
1896
)
1881
1897
except Exception as e :
@@ -1895,13 +1911,13 @@ def get_local_driver(
1895
1911
elif "DevToolsActivePort file doesn't exist" in e .msg :
1896
1912
service = EdgeService (
1897
1913
executable_path = LOCAL_EDGEDRIVER ,
1898
- log_path = os .path . devnull ,
1914
+ log_path = os .devnull ,
1899
1915
)
1900
1916
# https://stackoverflow.com/a/56638103/7058266
1901
1917
edge_options .add_argument ("--remote-debugging-port=9222" )
1902
1918
return Edge (service = service , options = edge_options )
1903
1919
if not auto_upgrade_edgedriver :
1904
- raise Exception ( e . msg ) # Not an obvious fix. Raise .
1920
+ raise # Not an obvious fix.
1905
1921
else :
1906
1922
pass # Try upgrading EdgeDriver to match Edge.
1907
1923
args = " " .join (sys .argv )
@@ -1921,7 +1937,7 @@ def get_local_driver(
1921
1937
_mark_driver_repaired ()
1922
1938
driver = Edge (
1923
1939
executable_path = LOCAL_EDGEDRIVER ,
1924
- service_log_path = os .path . devnull ,
1940
+ service_log_path = os .devnull ,
1925
1941
capabilities = capabilities ,
1926
1942
)
1927
1943
return driver
@@ -2076,7 +2092,7 @@ def get_local_driver(
2076
2092
if selenium4 :
2077
2093
service = ChromeService (
2078
2094
executable_path = LOCAL_CHROMEDRIVER ,
2079
- log_path = os .path . devnull ,
2095
+ log_path = os .devnull ,
2080
2096
)
2081
2097
driver = webdriver .Chrome (
2082
2098
service = service ,
@@ -2085,19 +2101,19 @@ def get_local_driver(
2085
2101
else :
2086
2102
driver = webdriver .Chrome (
2087
2103
executable_path = LOCAL_CHROMEDRIVER ,
2088
- service_log_path = os .path . devnull ,
2104
+ service_log_path = os .devnull ,
2089
2105
options = chrome_options ,
2090
2106
)
2091
2107
else :
2092
2108
if selenium4 :
2093
- service = ChromeService (log_path = os .path . devnull )
2109
+ service = ChromeService (log_path = os .devnull )
2094
2110
driver = webdriver .Chrome (
2095
2111
service = service , options = chrome_options
2096
2112
)
2097
2113
else :
2098
2114
driver = webdriver .Chrome (
2099
2115
options = chrome_options ,
2100
- service_log_path = os .path . devnull ,
2116
+ service_log_path = os .devnull ,
2101
2117
)
2102
2118
except Exception as e :
2103
2119
auto_upgrade_chromedriver = False
@@ -2106,7 +2122,7 @@ def get_local_driver(
2106
2122
elif "Chrome version must be between" in e .msg :
2107
2123
auto_upgrade_chromedriver = True
2108
2124
if not auto_upgrade_chromedriver :
2109
- raise Exception ( e . msg ) # Not an obvious fix. Raise .
2125
+ raise # Not an obvious fix.
2110
2126
else :
2111
2127
pass # Try upgrading ChromeDriver to match Chrome.
2112
2128
mcv = None # Major Chrome Version
@@ -2251,14 +2267,14 @@ def get_local_driver(
2251
2267
)
2252
2268
chrome_options .headless = False
2253
2269
return webdriver .Chrome (options = chrome_options )
2254
- except Exception as e :
2270
+ except Exception :
2255
2271
try :
2256
2272
# Try again if Chrome didn't launch
2257
2273
return webdriver .Chrome (options = chrome_options )
2258
2274
except Exception :
2259
2275
pass
2260
2276
if headless :
2261
- raise Exception ( e )
2277
+ raise
2262
2278
if LOCAL_CHROMEDRIVER and os .path .exists (LOCAL_CHROMEDRIVER ):
2263
2279
try :
2264
2280
make_driver_executable_if_not (LOCAL_CHROMEDRIVER )
0 commit comments