Merge pull request #380 from dsame/firefox-driver

Install Firefox(Gecko) webdriver to linux images
This commit is contained in:
Alena Sviridenko
2020-02-14 12:19:58 +03:00
committed by GitHub
5 changed files with 62 additions and 24 deletions

View File

@@ -23,3 +23,31 @@ echo "Lastly, documenting what we added to the metadata file"
# ($HOME is /home/packer which is owned by packer.) # ($HOME is /home/packer which is owned by packer.)
HOME=/root HOME=/root
DocumentInstalledItem "Firefox ($(firefox --version))" DocumentInstalledItem "Firefox ($(firefox --version))"
# Download and unpack latest release of geckodriver
URL=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest|grep 'browser_download_url.*linux64.tar.gz'|sed -E 's/^.*(https:.+)".*/\1/g')
echo "Downloading geckodriver $URL..."
wget "$URL" -O geckodriver.tar.gz
tar -xzf geckodriver.tar.gz
rm geckodriver.tar.gz
GECKODRIVER_DIR="/usr/local/share/gecko_driver"
GECKODRIVER_BIN="$GECKODRIVER_DIR/geckodriver"
mkdir -p $GECKODRIVER_DIR
mv "geckodriver" $GECKODRIVER_BIN
chmod +x $GECKODRIVER_BIN
ln -s "$GECKODRIVER_BIN" /usr/bin/
echo "GECKOWEBDRIVER=$GECKODRIVER_DIR" | 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"
ver=`./geckodriver --version|head -1|awk '{print $2}'`
DocumentInstalledItem "Geckodriver (${ver}); Gecko Driver is available via GECKOWEBDRIVER environment variable"

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
################################################################################ ################################################################################
## File: google-chrome.sh ## File: google-chrome.sh
## Desc: Installs google-chrome, chromedriver and selenium server ## Desc: Installs google-chrome and chromedriver
################################################################################ ################################################################################
# Source the helpers for use with the script # Source the helpers for use with the script
@@ -57,26 +57,3 @@ fi
echo "Lastly, documenting what we added to the metadata file" echo "Lastly, documenting what we added to the metadata file"
DocumentInstalledItem "Chromedriver ($(chromedriver --version)); Chrome Driver is available via CHROMEWEBDRIVER environment variable" DocumentInstalledItem "Chromedriver ($(chromedriver --version)); Chrome Driver is available via CHROMEWEBDRIVER environment variable"
# Determine latest selenium standalone server version
SELENIUM_LATEST_VERSION_URL=https://api.github.com/repos/SeleniumHQ/selenium/releases/latest
SELENIUM_VERSION=$(curl $SELENIUM_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d ' ' -f 2)
SELENIUM_VERSION_MAJOR_MINOR=$(echo $SELENIUM_VERSION | cut -d '.' -f 1,2)
# Download selenium standalone server
echo "Downloading selenium-server-standalone v$SELENIUM_VERSION..."
SELENIUM_JAR_NAME="selenium-server-standalone-$SELENIUM_VERSION.jar"
wget https://selenium-release.storage.googleapis.com/$SELENIUM_VERSION_MAJOR_MINOR/$SELENIUM_JAR_NAME
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if [ ! -f "$SELENIUM_JAR_NAME" ]; then
echo "Selenium server was not installed"
exit 1
fi
SELENIUM_JAR_PATH="/usr/share/java/selenium-server-standalone.jar"
mv $SELENIUM_JAR_NAME $SELENIUM_JAR_PATH
echo "SELENIUM_JAR_PATH=$SELENIUM_JAR_PATH" | tee -a /etc/environment
echo "Lastly, documenting what we added to the metadata file"
DocumentInstalledItem "Selenium server standalone (available via SELENIUM_JAR_PATH environment variable)"

View File

@@ -0,0 +1,31 @@
#!/bin/bash
################################################################################
## File: selenium.sh
## Desc: Installs selenium server
################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/document.sh
# Determine latest selenium standalone server version
SELENIUM_LATEST_VERSION_URL=https://api.github.com/repos/SeleniumHQ/selenium/releases/latest
SELENIUM_VERSION=$(curl $SELENIUM_LATEST_VERSION_URL | jq '.name' | tr -d '"' | cut -d ' ' -f 2)
SELENIUM_VERSION_MAJOR_MINOR=$(echo $SELENIUM_VERSION | cut -d '.' -f 1,2)
# Download selenium standalone server
echo "Downloading selenium-server-standalone v$SELENIUM_VERSION..."
SELENIUM_JAR_NAME="selenium-server-standalone-$SELENIUM_VERSION.jar"
wget https://selenium-release.storage.googleapis.com/$SELENIUM_VERSION_MAJOR_MINOR/$SELENIUM_JAR_NAME
echo "Testing to make sure that script performed as expected, and basic scenarios work"
if [ ! -f "$SELENIUM_JAR_NAME" ]; then
echo "Selenium server was not installed"
exit 1
fi
SELENIUM_JAR_PATH="/usr/share/java/selenium-server-standalone.jar"
mv $SELENIUM_JAR_NAME $SELENIUM_JAR_PATH
echo "SELENIUM_JAR_PATH=$SELENIUM_JAR_PATH" | tee -a /etc/environment
echo "Lastly, documenting what we added to the metadata file"
DocumentInstalledItem "Selenium server standalone (available via SELENIUM_JAR_PATH environment variable)"

View File

@@ -159,6 +159,7 @@
"{{template_dir}}/scripts/installers/ruby.sh", "{{template_dir}}/scripts/installers/ruby.sh",
"{{template_dir}}/scripts/installers/rust.sh", "{{template_dir}}/scripts/installers/rust.sh",
"{{template_dir}}/scripts/installers/sbt.sh", "{{template_dir}}/scripts/installers/sbt.sh",
"{{template_dir}}/scripts/installers/selenium.sh",
"{{template_dir}}/scripts/installers/sphinx.sh", "{{template_dir}}/scripts/installers/sphinx.sh",
"{{template_dir}}/scripts/installers/subversion.sh", "{{template_dir}}/scripts/installers/subversion.sh",
"{{template_dir}}/scripts/installers/terraform.sh", "{{template_dir}}/scripts/installers/terraform.sh",

View File

@@ -162,6 +162,7 @@
"{{template_dir}}/scripts/installers/ruby.sh", "{{template_dir}}/scripts/installers/ruby.sh",
"{{template_dir}}/scripts/installers/rust.sh", "{{template_dir}}/scripts/installers/rust.sh",
"{{template_dir}}/scripts/installers/sbt.sh", "{{template_dir}}/scripts/installers/sbt.sh",
"{{template_dir}}/scripts/installers/selenium.sh",
"{{template_dir}}/scripts/installers/sphinx.sh", "{{template_dir}}/scripts/installers/sphinx.sh",
"{{template_dir}}/scripts/installers/subversion.sh", "{{template_dir}}/scripts/installers/subversion.sh",
"{{template_dir}}/scripts/installers/terraform.sh", "{{template_dir}}/scripts/installers/terraform.sh",