Kaizen
Valued Contributor

this is what im using to install currently

 

# !/bin/bash

# Script: selenium_init.sh
# Description: Installs Chrome and Chromedriver with path assignment for Selenium.

set -x

sudo apt update
sudo apt upgrade -y 2>upgrade_errors.log

# install require chrome libraries
sudo apt-get update
sudo apt-get install fonts-liberation
sudo apt-get install libgbm1 -y
sudo apt-get install libu2f-udev -y

# create directory
TMP_DIR="tmp"
CHROME_DIR="${TMP_DIR}/chrome"
CHROMEDRIVER_DIR="${TMP_DIR}/chromedriver"

# do a clean install - delete all old drivers
rm -rf ${CHROME_DIR}
rm -rf ${CHROMEDRIVER_DIR}

mkdir -p ${CHROME_DIR}
mkdir -p ${CHROMEDRIVER_DIR}

cd ${CHROME_DIR}

# alternative google chrome download below is better for supporting latest version
# sudo dpkg -i google-chrome-stable_current_amd64.deb
# sudo apt-get install -f -y
# sudo apt-get update --fix-missing

# download chrome from same source as chromedriver
unzip chrome-linux64.zip
.chrome-linux64/chrome

google-chrome --version || echo "look into google-chrome install"

# install chromedriver -> find all driver files here: https://googlechromelabs.github.io/chrome-for-testing/
cd ..
cd ..
cd ${CHROMEDRIVER_DIR}

# download chromedriver
unzip chromedriver-linux64.zip
sudo chown root:root /databricks/driver/tmp/chromedriver
sudo chmod +x /databricks/driver/tmp/chromedriver

# TODO: path assignment is not persistant -> Likely permissions issue or databricks compute engine limitation
# Current workaround -> move to preassigned system path
# sudo export PATH=$PATH:/databricks/driver/tmp/chromedriver/chromedriver-linux64/

# copy file to a location defined in path
echo pwd
sudo cp -r chromedriver-linux64/chromedriver /databricks/.pyenv/bin
cd ..
sudo cp -r chrome/chrome-linux64 /databricks/.pyenv/bin

echo "copied file over- new file dir"
cd /databricks/.pyenv/bin
ls

echo "Script execution completed successfully"
echo "Chrome version:" $(google-chrome --version)
echo "Chromedriver version:" $(chromedriver --version)