How to install Chrome for Testing from zip file on Debian?

5.8k Views Asked by At

Using:

Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:    10
Codename:   buster

Google is now recommending that people use Chrome for Testing for their test automation instead of commercial version of Chrome and I can't find a way to make it work. This is originally how we did it in our pipeline:

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 -y update
apt-get -y install google-chrome-stable

But now using the new api for Chrome for Testing this is what I'm using in our shell script:

LATEST_CHROME_JSON=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq '.channels.Stable')
LATEST_CHROME_URL=$(echo "$LATEST_CHROME_JSON" | jq -r '.downloads.chrome[] | select(.platform == "linux64") | .url')
wget -N "$LATEST_CHROME_URL" -P ~/
unzip ~/chrome-linux64.zip -d ~/
rm ~/chrome-linux64.zip
mkdir -p /opt/chrome
mv ~/chrome-linux64/* /opt/chrome/
rm -r ~/chrome-linux64
ln -s /opt/chrome/chrome /usr/local/bin/chrome
chmod +x /opt/chrome/chrome
chrome --version

Everytime I use chrome --version the pipeline fails because some dependency or another is missing. How come I didn't need any of these dependencies before? And how do I have it print out all the required dependencies instead of erroring out one by one? Right now I keep adding a new dependency to install, commit and push, run my pipeline, only to see a brand new error and a brand new dependency is needed.

The dependencies I'm installing:

apt-get update
apt-get install -y unzip openjdk-8-jre-headless
apt-get install -y xvfb libxi6 libgconf-2-4 jq libjq1 libonig5 #xorg apt-get install -y jq libjq1 libonig5
apt-get install -y libnss3
apt-get install -y libatk1.0-0
apt-get install -y libatk-bridge2.0-0

I had to separate them because openjdk-8-jre-headless kept failing because for some reason it's missing or something. I remember getting this from this tutorial on installing chrome: https://gist.github.com/buttreygoodness/09e26d7f21eb5b95a4229658a7a9b321

As I post this, my pipeline just failed again this time with error

chrome: error while loading shared libraries: libcups.so.2: cannot open shared object file: No such file or directory

This is getting frustrating. There has to be a better way to install chrome from a zip file like this. I don't understand why they couldn't just make a .deb file like they normally do

1

There are 1 best solutions below

6
qathulu On

Finally worked by using these dependencies

apt-get install -y unzip xvfb libxi6 libgconf-2-4 jq libjq1 libonig5 libxkbcommon0 libxss1 libglib2.0-0 libnss3 \
  libfontconfig1 libatk-bridge2.0-0 libatspi2.0-0 libgtk-3-0 libpango-1.0-0 libgdk-pixbuf2.0-0 libxcomposite1 \
  libxcursor1 libxdamage1 libxtst6 libappindicator3-1 libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libxfixes3 \
  libdbus-1-3 libexpat1 libgcc1 libnspr4 libgbm1 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxext6 \
  libxrandr2 libxrender1 gconf-service ca-certificates fonts-liberation libappindicator1 lsb-release xdg-utils

LATEST_CHROME_RELEASE=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq '.channels.Stable')
LATEST_CHROME_URL=$(echo "$LATEST_CHROME_RELEASE" | jq -r '.downloads.chrome[] | select(.platform == "linux64") | .url')
wget -N "$LATEST_CHROME_URL" -P ~/
unzip ~/chrome-linux64.zip -d ~/
mv ~/chrome-linux64 ~/chrome
ln -s ~/chrome/chrome /usr/local/bin/chrome
chmod +x ~/chrome
rm ~/chrome-linux64.zip