Skip to content

Commit d31889e

Browse files
committed
Add support for multiple drivers
1 parent eff35ce commit d31889e

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

seleniumbase/console_scripts/sb_install.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
from seleniumbase.fixtures import shared_utils
4545
from seleniumbase import config as sb_config
4646
from seleniumbase import drivers # webdriver storage folder for SeleniumBase
47+
from seleniumbase.drivers import cft_drivers # chrome-for-testing
48+
from seleniumbase.drivers import chs_drivers # chrome-headless-shell
4749

4850
urllib3.disable_warnings()
4951
ARCH = platform.architecture()[0]
@@ -52,6 +54,8 @@
5254
IS_LINUX = shared_utils.is_linux()
5355
IS_WINDOWS = shared_utils.is_windows()
5456
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
57+
DRIVER_DIR_CFT = os.path.dirname(os.path.realpath(cft_drivers.__file__))
58+
DRIVER_DIR_CHS = os.path.dirname(os.path.realpath(chs_drivers.__file__))
5559
LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
5660
DEFAULT_CHROMEDRIVER_VERSION = "114.0.5735.90" # (If can't find LATEST_STABLE)
5761
DEFAULT_GECKODRIVER_VERSION = "v0.36.0"
@@ -305,6 +309,17 @@ def main(override=None, intel_for_uc=None, force_uc=None):
305309
headless_ie_exists = False
306310
headless_ie_file_name = None
307311
downloads_folder = DRIVER_DIR
312+
if (
313+
hasattr(sb_config, "settings")
314+
and hasattr(sb_config.settings, "NEW_DRIVER_DIR")
315+
and sb_config.settings.NEW_DRIVER_DIR
316+
and os.path.exists(sb_config.settings.NEW_DRIVER_DIR)
317+
):
318+
downloads_folder = sb_config.settings.NEW_DRIVER_DIR
319+
elif override == "cft" or name == "cft":
320+
downloads_folder = DRIVER_DIR_CFT
321+
elif override == "chs" or name == "chs":
322+
downloads_folder = DRIVER_DIR_CHS
308323
expected_contents = None
309324
platform_code = None
310325
copy_to_path = False

seleniumbase/core/browser_launcher.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
from seleniumbase import config as sb_config
2626
from seleniumbase import decorators
2727
from seleniumbase import drivers # webdriver storage folder for SeleniumBase
28+
from seleniumbase.drivers import cft_drivers # chrome-for-testing
29+
from seleniumbase.drivers import chs_drivers # chrome-headless-shell
2830
from seleniumbase import extensions # browser extensions storage folder
2931
from seleniumbase.config import settings
3032
from seleniumbase.core import detect_b_ver
@@ -39,6 +41,8 @@
3941

4042
urllib3.disable_warnings()
4143
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
44+
DRIVER_DIR_CFT = os.path.dirname(os.path.realpath(cft_drivers.__file__))
45+
DRIVER_DIR_CHS = os.path.dirname(os.path.realpath(chs_drivers.__file__))
4246
# Make sure that the SeleniumBase DRIVER_DIR is at the top of the System PATH
4347
# (Changes to the System PATH with os.environ only last during the test run)
4448
if not os.environ["PATH"].startswith(DRIVER_DIR):
@@ -2833,6 +2837,18 @@ def get_driver(
28332837
device_pixel_ratio=None,
28342838
browser=None, # A duplicate of browser_name to avoid confusion
28352839
):
2840+
driver_dir = DRIVER_DIR
2841+
if sb_config.binary_location == "cft":
2842+
driver_dir = DRIVER_DIR_CFT
2843+
if sb_config.binary_location == "chs":
2844+
driver_dir = DRIVER_DIR_CHS
2845+
if (
2846+
hasattr(sb_config, "settings")
2847+
and hasattr(sb_config.settings, "NEW_DRIVER_DIR")
2848+
and sb_config.settings.NEW_DRIVER_DIR
2849+
and os.path.exists(sb_config.settings.NEW_DRIVER_DIR)
2850+
):
2851+
driver_dir = sb_config.settings.NEW_DRIVER_DIR
28362852
if not browser_name:
28372853
if browser:
28382854
browser_name = browser

seleniumbase/drivers/cft_drivers/__init__.py

Whitespace-only changes.

seleniumbase/drivers/chs_drivers/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)