Skip to content
This repository was archived by the owner on Jun 12, 2024. It is now read-only.
This repository was archived by the owner on Jun 12, 2024. It is now read-only.

Error: 'chromedriver' executable needs to be in PATH. #14

Description

@as3379

I have implemented your dockfile into my project which uses webdriver chrome to run the python test script (using mac OS) . However when tried, it errors out as follows:

image

Docker file:

Use an official Python runtime as a parent image

FROM python:3.7
ENV APP_DIR /app
WORKDIR $APP_DIR

ENV PYTHONPATH="$PYTHONPATH:/app"

COPY uits uits
COPY requirements.txt requirements.txt
COPY setup.py setup.py

install google chrome

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get -y update
RUN apt-get install -y google-chrome-stable

install chromedriver

RUN apt-get install -yqq unzip
RUN wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip
RUN unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/

set display port to avoid crash

ENV DISPLAY=:99

install selenium

RUN pip install selenium

upgrade pip

RUN pip install --upgrade pip

#install required additional dependencies
RUN pip install -r requirements.txt

Test script look like this:

class SeleniumClient(object):
"""
A wrapper for selenium's client with various handy extensions.
"""
def init(self, params=None, config="default", driver=None):
if driver is not None:
self.driver = driver
return

    if params['location'] != "local":
        return

    root = os.path.dirname(os.path.realpath(__file__))
    self.logger.info("%s" , _platform)
    if _platform == "darwin":
        user = getpass.getuser()
        download_folder = "/Users/%s/downloads/" % user
    elif "win32" in _platform:
        user = getpass.getuser()
        download_folder = "/Users/%s/downloads/" % user
    elif "linux" in _platform:
        download_folder = "/var/lib/docker"
    else:
        raise NotImplemented("don't know where to save data")
    if "chrome" in config:
        options = webdriver.ChromeOptions()
        preferences = {
            "profile.default_content_settings.popups": 0,
            "download.default_directory": download_folder,
            "credentials_enable_service": 0,
            "profile.password_manager_enabled": 0
        }
        options.add_experimental_option("prefs", preferences)
        if config == "chrome":
            options.add_argument("--start-fullscreen")
        elif config == "chrome_headless":
            options.add_argument('--headless')
            options.add_argument('--disable-gpu')
            options.add_argument("--window-size=1920, 1200")
        self.driver = webdriver.Chrome(executable_path='usr/bin/local',options=options)

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions