Hi,
I have tried to setup Dockerfile and run script for alternative browsing with Chrome for testing web pages with Selenium.
Do I need selenium standalone server if i have selenium installed to Ubuntu? Or is chromedriver enough? How this is working with Chrome.
I have Docker image with Ubuntu 14.04 and I try to setup Chrome, but browser is not opened with this kind of setup:
Dockerfile:
FROM ubuntu:14.04
RUN adduser --disabled-password --gecos '' user
RUN adduser user sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER user
# Install old version of firefox + dependencies
RUN sudo apt-get update --fix-missing && \
sudo apt-get install -y wget libgtk-3-0 libasound2 libdbus-glib-1-2 \
git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl \
x11vnc xvfb
RUN sudo apt-get purge firefox
# Install old version of firefox
RUN sudo wget -O firefox-mozilla-build_46.0.1-0ubuntu1_amd64.deb 'https://sourceforge.net/projects/ubuntuzilla/files/mozilla/apt/pool/main/f/firefox-mozilla-build/firefox-mozilla-build_46.0.1-0ubuntu1_amd64.deb'
RUN sudo dpkg -i firefox-mozilla-build_46.0.1-0ubuntu1_amd64.deb
# Install new version of firefox with geckodriver
# RUN sudo wget -O firefox-mozilla-build_ubuntu1_amd64.deb 'https://sourceforge.net/projects/ubuntuzilla/files/mozilla/apt/pool/main/f/firefox-mozilla-build/firefox-mozilla-build_52.0.2-0ubuntu1_amd64.deb'
# RUN sudo dpkg -i firefox-mozilla-build_ubuntu1_amd64.deb
# Geckodriver: Download, unarchive and move to PATH
# RUN sudo wget -O geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.15.0/geckodriver-v0.15.0-linux64.tar.gz
# RUN sudo tar -xzvf geckodriver.tar.gz
# RUN mkdir $HOME/drivers
# RUN sudo mv geckodriver $HOME/drivers
# RUN sudo chmod -R 777 $HOME/drivers
# ENV PATH="/home/user/drivers:${PATH}"
# Install dependencies.
RUN sudo apt-get update
RUN sudo apt-get install -y openjdk-7-jre-headless xvfb libxi6 libgconf-2-4 unzip
# Install Chrome.
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
RUN sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN sudo apt-get update
RUN sudo apt-get install -y google-chrome-stable
# Install ChromeDriver.
RUN wget -N http://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip -P ~/
RUN unzip ~/chromedriver_linux64.zip -d ~/
RUN rm ~/chromedriver_linux64.zip
RUN sudo mv -f ~/chromedriver /usr/local/share/
RUN sudo chmod +x /usr/local/share/chromedriver
RUN sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
# Install Selenium. Do I Need Selenium-server if I have installed selenium to Ubuntu???!!!
RUN sudo wget -N http://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar -P ~/
RUN sudo mv -f ~/selenium-server-standalone-3.0.1.jar /usr/local/share/
RUN sudo chmod +x /usr/local/share/selenium-server-standalone-3.0.1.jar
RUN sudo ln -s /usr/local/share/selenium-server-standalone-3.0.1.jar /usr/local/bin/selenium-server-standalone-3.0.1.jar
# Install Pyenv
RUN sudo apt-get install -y git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl python-tk tk-dev
RUN sudo pip install virtualenvwrapper
ENV HOME /home/user
RUN git clone https://github.com/yyuu/pyenv.git $HOME/.pyenv
RUN git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git $HOME/.pyenv/plugins/pyenv-virtualenvwrapper
RUN git clone https://github.com/yyuu/pyenv-virtualenv.git $HOME/.pyenv/plugins/pyenv-virtualenv
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH $PYENV_ROOT/bin:$PATH
RUN python --version
# Install python versions you want under here
RUN pyenv install 2.7.13
RUN pyenv rehash
# Set the default python version you want to use
ENV PYTHON_VERSION 2.7.13
RUN pyenv global $PYTHON_VERSION
RUN pyenv versions
RUN pyenv global
RUN eval "$(pyenv init -)"
RUN eval "$(pyenv virtualenv-init -)"
# These pip modules are used with older firefox
# RUN $HOME/.pyenv/versions/$PYTHON_VERSION/bin/pip install --upgrade pip && \
# $HOME/.pyenv/versions/$PYTHON_VERSION/bin/pip install requests && \
# $HOME/.pyenv/versions/$PYTHON_VERSION/bin/pip install robotframework robotframework-selenium2library selenium==2.53.6 robotframework-xvfb robotframework-extendedselenium2library && \
# $HOME/.pyenv/versions/$PYTHON_VERSION/bin/pip install robotframework-imaplibrary==0.3.0 robotframework-requests robotframework-sudslibrary beautifulsoup4
# $HOME/.pyenv/versions/$PYTHON_VERSION/bin/pip install robotframework robotframework-selenium2library selenium==2.53.6 robotframework-xvfb robotframework-extendedselenium2library
# These pip modules are used with latest firefox
RUN $HOME/.pyenv/versions/$PYTHON_VERSION/bin/pip install --upgrade pip && \
$HOME/.pyenv/versions/$PYTHON_VERSION/bin/pip install requests && \
$HOME/.pyenv/versions/$PYTHON_VERSION/bin/pip install robotframework robotframework-selenium2library selenium==3.3.0 robotframework-xvfb robotframework-extendedselenium2library && \
$HOME/.pyenv/versions/$PYTHON_VERSION/bin/pip install robotframework-imaplibrary==0.3.0 robotframework-requests robotframework-sudslibrary beautifulsoup4
RUN mkdir ~/.vnc
RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
COPY run.sh /usr/local/bin/run.sh
RUN sudo chmod +x /usr/local/bin/run.sh
CMD ["run.sh"]
The I try to start Chrome in run.sh but I cannot get Chrom browser open with Robot keyword:
Open Browser ${url} browser=chrome
run.sh script for Xvfb looks like this for Chrome:
xvfb-run -ac --server-args='-screen 0, ${RES}' google-chrome -start-maximized > /dev/null 2>&1 &
Working Xvfb line in run.sh with Firefox is like this:
Xvfb ${DISPLAY} -screen 0 ${RES} -ac > /dev/null 2>&1 &How I could "replace" Firefox with Chrome?
I would be appreciated of your help.
Cheers
Sami