Selenium Firefox webdriver works on images built from Ubuntu but not on images built from Debian Selenium Firefox webdriver works on images built from Ubuntu but not on images built from Debian selenium selenium

Selenium Firefox webdriver works on images built from Ubuntu but not on images built from Debian


RUN apt-get install -y --no-install-recommends apt-utilsRUN apt-get install -y wget \        build-essential \        libgl1-mesa-glx \        libgtk-3-dev ARG FIREFOX_VERSION=58.0.2RUN wget --no-verbose -O /tmp/firefox.tar.bz2 https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2 \   && rm -rf /opt/firefox \   && tar -C /opt -xjf /tmp/firefox.tar.bz2 \   && rm /tmp/firefox.tar.bz2 \   && mv /opt/firefox /opt/firefox-$FIREFOX_VERSION \   && ln -fs /opt/firefox-$FIREFOX_VERSION/firefox /usr/bin/firefoxARG GK_VERSION=v0.19.1RUN wget --no-verbose -O /tmp/geckodriver.tar.gz http://github.com/mozilla/geckodriver/releases/download/$GK_VERSION/geckodriver-$GK_VERSION-linux64.tar.gz \   && rm -rf /opt/geckodriver \   && tar -C /opt -zxf /tmp/geckodriver.tar.gz \   && rm /tmp/geckodriver.tar.gz \   && mv /opt/geckodriver /opt/geckodriver-$GK_VERSION \   && chmod 755 /opt/geckodriver-$GK_VERSION \   && ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver

Making the following changes based on what @Florent B. had linked was the fix for it. Essentially firefox-esr is version 52 and the -headless option for Firefox was released in version 55. I am not sure what version iceweasel is but presumably it is earlier than that. Additionally versions of Firefox above 52 will not work without libgtk-3. I presume Debian 8 still has libgtk-2 so one would need to install that as well. Headless browsing works perfect with build-essential, libgtk-3-dev, wget, and libgl1-mesa-glx on Debian 8.


You should never install Firefox using package manager. You can find all the firefox releases on below link

https://download-installer.cdn.mozilla.net/pub/firefox/releases/

If you look at the Selenium Firefox Dockerfile

https://github.com/SeleniumHQ/docker-selenium/blob/master/NodeFirefox/Dockerfile

They download the required version using

wget --no-verbose -O /tmp/firefox.tar.bz2 $FIREFOX_DOWNLOAD_URL

And for dependencies issues they run the below command

apt-get -qqy --no-install-recommends install firefox

And then later remove the firefox package

apt-get -y purge firefox

This makes sure that you don't need to worry about all required dependencies. If you want you can still get dependencies

$ apt-cache depends firefox | grep Depends  Depends: lsb-release  Depends: libatk1.0-0  Depends: libc6  Depends: libcairo-gobject2  Depends: libcairo2  Depends: libdbus-1-3  Depends: libdbus-glib-1-2  Depends: libfontconfig1  Depends: libfreetype6  Depends: libgcc1  Depends: libgdk-pixbuf2.0-0  Depends: libglib2.0-0  Depends: libgtk-3-0  Depends: libpango-1.0-0  Depends: libpangocairo-1.0-0  Depends: libstartup-notification0  Depends: libstdc++6  Depends: libx11-6  Depends: libx11-xcb1  Depends: libxcb-shm0  Depends: libxcb1  Depends: libxcomposite1  Depends: libxdamage1  Depends: libxext6  Depends: libxfixes3  Depends: libxrender1  Depends: libxt6

If you look at the below link

https://developer.mozilla.org/en-US/Firefox/Headless_mode

Browser support

Headless Firefox works on Fx55+ on Linux, and 56+ on Windows/Mac.