How to Add Chromedriver to Path in Linux

How to add Chromedriver to PATH in linux?

You can specify the absolute path to your chrome driver in your script as such:

from selenium import webdriver
driver = webdriver.Chrome(executable_path='/path/to/driver/chromedriver')

Or you can add the path to your webdriver in the PATH system variable as so:

export PATH=$PATH:/path/to/driver/chrome-driver

You may add the above line to your /home/<user>/.profile file to make it permanent.

Tested on Ubuntu 17.10 running Python 2.7.14

Hope this helps!

Unable to set the path for chromedriver from Ubuntu

You're using Ubuntu, but chromedriver.exe is a windows version of chromedriver.
Get the correct one from https://chromedriver.storage.googleapis.com/index.html?path=2.35/ (latest one at the moment..)
Correct Linux chromedriver version will not have the .exe extension.

Using selenium chromedriver and python with chromium on Linux

I am no authority on this but when checking the github source code for selenium, one can see that the default value for executable_path (which is deprecated in their repo by the way) is just chromedriver (Line 34 in webdriver.Chrome).

It then just runs this command per subprocess. This means only the paths in the environment variable $PATH will be search through. Selenium does not carry out any search by themselves.

You can read here, how you can add the path to your chromium webdriver to the environment variable.

Chromedriver executable path not found in Docker Container

I have found the problem, you need to add the all the python files into the Dockerfile. Please find the Dockerfile to install the Chromedriver and Chrome onto the image and the default path for the chromedriver within the container.

Dockerfile

FROM python:3.9

ADD /app/main.py .
ADD /app/connectdriver.py .

# Install Chrome WebDriver
RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
rm /tmp/chromedriver_linux64.zip && \
chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver

# Install Google Chrome
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yqq update && \
apt-get -yqq install google-chrome-stable && \
rm -rf /var/lib/apt/lists/*

COPY requirements.txt .

RUN pip install -r requirements.txt

WORKDIR /seleniumtesting

COPY ./app ./app


CMD ["python","./app/main.py"]

python driver script

driver = webdriver.Chrome(options=options, executable_path='/usr/local/bin/chromedriver')


Related Topics



Leave a reply



Submit