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

Fix: Incorrect error thrown when missing chrome/geckodriver #749

Merged
merged 2 commits into from
Dec 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions splinter/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ def get_driver(driver, retry_count=3, *args, **kwargs):
This can mitigate issues running on Remote WebDriver.

"""
err = None

for _ in range(retry_count):
try:
return driver(*args, **kwargs)
except (IOError, HTTPException, WebDriverException, MaxRetryError) as e:
pass
err = e

raise e
raise err


def Browser(driver_name="firefox", retry_count=3, *args, **kwargs):
Expand Down
15 changes: 15 additions & 0 deletions tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

from splinter.exceptions import DriverNotFoundError

from selenium.common.exceptions import WebDriverException

import pytest

from .fake_webapp import EXAMPLE_APP


Expand Down Expand Up @@ -57,3 +61,14 @@ def test_should_raise_an_exception_when_browser_driver_is_not_found(self):
from splinter import Browser

Browser("unknown-driver")


@pytest.mark.parametrize('browser_name', ['chrome', 'firefox'])
def test_local_driver_not_present(browser_name):
"""When chromedriver/geckodriver are not present on the system."""
from splinter import Browser

with pytest.raises(WebDriverException) as e:
Browser(browser_name, executable_path='failpath')

assert "Message: 'failpath' executable needs to be in PATH." in str(e.value)