Skip to content

Misleading error message when selenium is not installed #1328

Open

Description

@turicas

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions