Skip to content

Commit f47185e

Browse files
committed
Have the seleniumbase/drivers folder take PATH priority
1 parent 7b5c542 commit f47185e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@
2020
from seleniumbase import extensions # browser extensions storage folder
2121
urllib3.disable_warnings()
2222
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
23-
if DRIVER_DIR not in os.environ["PATH"]:
23+
# Make sure that the SeleniumBase DRIVER_DIR is at the top of the System PATH
24+
# (Changes to the System PATH with os.environ only last during the test run)
25+
if not os.environ["PATH"].startswith(DRIVER_DIR):
26+
# Remove existing SeleniumBase DRIVER_DIR from System PATH if present
27+
os.environ["PATH"] = os.environ["PATH"].replace(DRIVER_DIR, "")
28+
# If two path separators are next to each other, replace with just one
29+
os.environ["PATH"] = os.environ["PATH"].replace(
30+
os.pathsep + os.pathsep, os.pathsep)
31+
# Put the SeleniumBase DRIVER_DIR at the beginning of the System PATH
2432
os.environ["PATH"] = DRIVER_DIR + os.pathsep + os.environ["PATH"]
2533
EXTENSIONS_DIR = os.path.dirname(os.path.realpath(extensions.__file__))
2634
DISABLE_CSP_ZIP_PATH = "%s/%s" % (EXTENSIONS_DIR, "disable_csp.zip")

0 commit comments

Comments
 (0)