Last active
April 20, 2025 03:53
-
-
Save cgoldberg/5e14e95c7e1fd4d9281d25b4edb43422 to your computer and use it in GitHub Desktop.
Bash script to download Selenium Manager binary for Linux to local selenium source tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# This script downloads the latest stable version of the `selenium-manager` binary | |
# for Linux (x86-64) from `https://github.com/SeleniumHQ/selenium_manager_artifacts/releases` | |
# | |
# Before running this script, you should have the selenium repo cloned locally: | |
# $ git clone --filter=blob:none [email protected]:SeleniumHQ/selenium.git | |
# | |
# Make sure to set the `SELENIUM_HOME` variable below to match the repo's base directory. | |
# | |
# When you run this script, it will download the binary to the directory in your repo | |
# where the selenium webdriver Python package expects it to be. | |
set -e | |
# set this to match the directory of your selenium repo | |
SELENIUM_HOME=~/code/selenium/ | |
if [ ! "$(uname -s)" == "Linux" ]; then | |
echo "this script only works on Linux" | |
exit 1 | |
fi | |
sel_mgr_bin="selenium-manager" | |
sel_mgr_path="${SELENIUM_HOME%/}/py/selenium/webdriver/common/linux" | |
sel_mgr_bin_path="${sel_mgr_path}/${sel_mgr_bin}" | |
sel_build_url="https://github.com/SeleniumHQ/selenium/blob/trunk/common/selenium_manager.bzl" | |
sel_mgr_url=$( | |
curl -s "${sel_build_url}" 2>/dev/null | \ | |
grep -oE "url = .*?${sel_mgr_bin}-linux" | \ | |
cut -d= -f2 | cut -c4- | |
) | |
mkdir -p -v "${sel_mgr_path}" | |
echo "downloading ${sel_mgr_url} ..." | |
wget --quiet --hsts-file=/dev/null "${sel_mgr_url}" -O "${sel_mgr_bin_path}" | |
if [ -f "${sel_mgr_bin_path}" ]; then | |
chmod +x "${sel_mgr_bin_path}" | |
echo "downloaded binary to: ${sel_mgr_bin_path}" | |
else | |
echo "oops... can't find the binary" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment