Skip to content

Commit 9d98cf1

Browse files
committed
Specify the driver executable_path as needed
1 parent 14c45cb commit 9d98cf1

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,13 @@ def get_local_driver(
11291129
capabilities=firefox_capabilities, options=firefox_options
11301130
)
11311131
else:
1132-
return webdriver.Firefox(options=firefox_options)
1132+
if os.path.exists(LOCAL_GECKODRIVER):
1133+
return webdriver.Firefox(
1134+
executable_path=LOCAL_GECKODRIVER,
1135+
options=firefox_options,
1136+
)
1137+
else:
1138+
return webdriver.Firefox(options=firefox_options)
11331139
elif browser_name == constants.Browser.INTERNET_EXPLORER:
11341140
if not IS_WINDOWS:
11351141
raise Exception(
@@ -1534,7 +1540,13 @@ def get_local_driver(
15341540
sys.argv = sys_args # Put back original sys args
15351541
if not headless or "linux" not in PLATFORM:
15361542
try:
1537-
driver = webdriver.Chrome(options=chrome_options)
1543+
if os.path.exists(LOCAL_CHROMEDRIVER):
1544+
driver = webdriver.Chrome(
1545+
executable_path=LOCAL_CHROMEDRIVER,
1546+
options=chrome_options,
1547+
)
1548+
else:
1549+
driver = webdriver.Chrome(options=chrome_options)
15381550
except Exception as e:
15391551
auto_upgrade_chromedriver = False
15401552
if "This version of ChromeDriver only supports" in e.msg:
@@ -1599,7 +1611,13 @@ def get_local_driver(
15991611
chrome_options, headless_options
16001612
)
16011613
_mark_chromedriver_repaired()
1602-
driver = webdriver.Chrome(options=chrome_options)
1614+
if os.path.exists(LOCAL_CHROMEDRIVER):
1615+
driver = webdriver.Chrome(
1616+
executable_path=LOCAL_CHROMEDRIVER,
1617+
options=chrome_options,
1618+
)
1619+
else:
1620+
driver = webdriver.Chrome(options=chrome_options)
16031621
return driver
16041622
else: # Running headless on Linux
16051623
try:

0 commit comments

Comments
 (0)