Skip to content

Commit

Permalink
use shutil.which() in SeleniumChromiumTestCase()
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie committed Feb 19, 2020
1 parent 27a4b8a commit b0336b0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions django_tools/selenium/chromedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
:copyleft: 2015-2020 by the django-tools team, see AUTHORS for more details.
:license: GNU GPL v3 or above, see LICENSE for more details.
"""

import logging
import shutil

from selenium import webdriver
from selenium.webdriver import DesiredCapabilities

# https://github.com/jedie/django-tools
from django_tools.selenium.base import SeleniumBaseTestCase
from django_tools.selenium.utils import find_executable


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -40,12 +41,8 @@ def test_admin_login_page(self):
see also: django_tools_tests/test_unittest_selenium.py
"""

filename = "chromedriver"

# Overwrite this in sub class, if needed:
extra_search_paths = ("/usr/lib/chromium-browser",)

options = ("--no-sandbox", "--headless", "--disable-gpu")
desired_capabilities = {
"loggingPrefs": {
Expand All @@ -66,7 +63,7 @@ def setUpClass(cls):
options.add_argument(argument)

try:
executable = find_executable(cls.filename, cls.extra_search_paths)
executable = shutil.which(cls.filename)
except FileNotFoundError:
cls.driver = None
else:
Expand Down Expand Up @@ -108,7 +105,7 @@ def chromium_available(filename=None):
filename = SeleniumChromiumTestCase.filename

try:
executable = find_executable(filename, SeleniumChromiumTestCase.extra_search_paths)
executable = shutil.which(filename)
except FileNotFoundError as err:
log.error("Chromium is no available: %s", err)
return False
Expand Down

0 comments on commit b0336b0

Please sign in to comment.