cobrateam / cobrateam/splinter

Misleading error message when selenium is not installed

Open
#1,328 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.7k
Forks
511
PR merge metrics
No merged PRs in 30d

Description

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

```python
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`](https://github.com/cobrateam/splinter/blob/master/splinter/browser.py#L38):

```python
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](https://github.com/cobrateam/splinter/blob/master/splinter/browser.py#L99):

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.