From 8fd8a8d31d21374fc4b34e08e2318e09fce4a457 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 7 Feb 2020 13:07:41 +0500 Subject: [PATCH] Add Gecko webdriver to linux images --- images/linux/scripts/installers/firefox.sh | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/images/linux/scripts/installers/firefox.sh b/images/linux/scripts/installers/firefox.sh index e14df0c4..ac514248 100644 --- a/images/linux/scripts/installers/firefox.sh +++ b/images/linux/scripts/installers/firefox.sh @@ -23,3 +23,26 @@ echo "Lastly, documenting what we added to the metadata file" # ($HOME is /home/packer which is owned by packer.) HOME=/root DocumentInstalledItem "Firefox ($(firefox --version))" + +# Download and unpack latest release of geckodriver +URL=https:`curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest|grep 'browser_download_url.*linux64.tar.gz'|sed -e 's/^.*"https://'|sed -e 's/"//g'` +echo "Downloading geckodriver $URL..." +wget "$URL" -O geckodriver.tar.gz +tar -xzf geckodriver.tar.gz +rm geckodriver.tar.gz + +GECKODRIVER_BIN="/usr/bin/geckodriver" +mv "geckodriver" $GECKODRIVER_BIN +chown root:root $GECKODRIVER_BIN +chmod +x $GECKODRIVER_BIN +echo "GECKOWEBDRIVER=$GECKODRIVER_BIN" | tee -a /etc/environment + +# Run tests to determine that the geckodriver installed as expected +echo "Testing to make sure that script performed as expected, and basic scenarios work" +if ! command -v geckodriver; then + echo "geckodriver was not installed" + exit 1 +fi + +echo "Lastly, documenting what we added to the metadata file" +DocumentInstalledItem "Geckodriver ($(geckodriver --version)); Gecko Driver is available via GECKOWEBDRIVER environment variable"