Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading error message when selenium is not installed #1328

Open
turicas opened this issue Feb 12, 2025 · 0 comments
Open

Misleading error message when selenium is not installed #1328

turicas opened this issue Feb 12, 2025 · 0 comments

Comments

@turicas
Copy link
Contributor

turicas commented Feb 12, 2025

I have a virtualenv with splinter installed and tried to run this code:

from splinter import Browser
browser = Browser("firefox")

Then, this error happened:

splinter.exceptions.DriverNotFoundError: Driver for firefox was not found.

But geckodriver was in my $PATH, so the driver exists.

By inspecting splinter code I found this try/except:

try:
    from splinter.driver.webdriver.chrome import WebDriver as ChromeWebDriver
    from splinter.driver.webdriver.firefox import WebDriver as FirefoxWebDriver
    from splinter.driver.webdriver.remote import WebDriver as RemoteWebDriver

    _DRIVERS["chrome"] = ChromeWebDriver
    _DRIVERS["firefox"] = FirefoxWebDriver
    _DRIVERS["remote"] = RemoteWebDriver
except ImportError as e:
    logger.debug(f"Import Warning: {e}")

This is going to fail if selenium is not installed, which will lead to this misleading error message in Browser function:

    if driver is None:
        raise DriverNotFoundError(f"Driver for {driver_name} was not found.")

This message seems to be related to the driver executable itself (like geckodriver, chromedriver etc.), not for missing selenium (the concepts of a splinter driver and a selenium driver mix here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant