Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install Chrome Driver with Xvfb (Ubuntu Server)
#!/bin/bash
# Chrome Repo
sudo apt-get install fonts-liberation xdg-utils libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
sudo apt-get update
# Download
wget https://chromedriver.storage.googleapis.com/2.22/chromedriver_linux64.zip
#Extract
unzip chromedriver_linux64.zip
# Deploy + Permissions
sudo cp ./chromedriver /usr/bin/
sudo chmod ugo+rx /usr/bin/chromedriver
# Install Google Chrome:
sudo apt-get -y install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4
# Dependencies to make "headless" chrome/selenium work:
sudo apt-get -y install xorg xvfb gtk2-engines-pixbuf
sudo apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable
# Optional but nifty: For capturing screenshots of Xvfb display:
sudo apt-get -y install imagemagick x11-apps
# Make sure that Xvfb starts everytime the box/vm is booted:
echo "Starting X virtual framebuffer (Xvfb) in background..."
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99
# Optionally, capture screenshots using the command:
#xwd -root -display :99 | convert xwd:- screenshot.png
@Mifrill

This comment has been minimized.

Copy link

commented Aug 13, 2017

Failure/Error: Timeout.timeout(60, &example)
          Selenium::WebDriver::Error::UnknownError:
            unknown error: Chrome failed to start: crashed
              (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Linux 4.10.0-32-generic x86_64)

any ideas?

@stefanjaro

This comment has been minimized.

Copy link

commented Apr 19, 2018

Thank you! This managed to get my script up and running on an Ubuntu Server running on an AWS EC2 instance.

For anybody seeing this in 2018, just replace the chromedriver link with a link to the latest version of chromedriver. As of the time of writing, that is:
wget https://chromedriver.storage.googleapis.com/2.38/chromedriver_linux64.zip

You may face some dependency issues when trying to dpkg chrome, but just read the error message, it'll contain the command you need to run to install the required packages. I believe that's:
sudo apt-get install -f

Also you'll need to get unzip for the 14th line to work:
sudo apt-get install unzip

@radinsky

This comment has been minimized.

Copy link

commented Apr 22, 2018

Failing with 2.38 driver as well:

WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 4.4.0-116-generic x86_64)
@matiit

This comment has been minimized.

Copy link

commented Nov 24, 2018

@radinsky, this error generally arises when google chrome can't start because it's tried to be run as root.
Try adding --no-sandbox option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.