File tree Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -1704,7 +1704,46 @@ def get_local_driver(
1704
1704
else : # Running headless on Linux
1705
1705
try :
1706
1706
return webdriver .Chrome (options = chrome_options )
1707
- except Exception :
1707
+ except Exception as e :
1708
+ auto_upgrade_chromedriver = False
1709
+ if "This version of ChromeDriver only supports" in e .msg :
1710
+ auto_upgrade_chromedriver = True
1711
+ elif "Chrome version must be between" in e .msg :
1712
+ auto_upgrade_chromedriver = True
1713
+ if auto_upgrade_chromedriver :
1714
+ args = " " .join (sys .argv )
1715
+ if (
1716
+ "-n" in sys .argv
1717
+ or " -n=" in args
1718
+ or args == "-c"
1719
+ ):
1720
+ import fasteners
1721
+
1722
+ chromedr_fixing_lock = fasteners .InterProcessLock (
1723
+ constants .MultiBrowser .CHROMEDRIVER_FIXING_LOCK
1724
+ )
1725
+ with chromedr_fixing_lock :
1726
+ if not _was_chromedriver_repaired ():
1727
+ try :
1728
+ _repair_chromedriver (
1729
+ chrome_options , chrome_options
1730
+ )
1731
+ _mark_chromedriver_repaired ()
1732
+ except Exception :
1733
+ pass
1734
+ else :
1735
+ if not _was_chromedriver_repaired ():
1736
+ try :
1737
+ _repair_chromedriver (
1738
+ chrome_options , chrome_options
1739
+ )
1740
+ except Exception :
1741
+ pass
1742
+ _mark_chromedriver_repaired ()
1743
+ try :
1744
+ return webdriver .Chrome (options = chrome_options )
1745
+ except Exception :
1746
+ pass
1708
1747
# Use the virtual display on Linux during headless errors
1709
1748
logging .debug (
1710
1749
"\n Warning: Chrome failed to launch in"
You can’t perform that action at this time.
0 commit comments