在CI上运行自动化测试。目前,我们正在检索最新版本的Chrome和Firefox作为我们设置的一部分,然而,我们使用的chromedriver和geckodriver的版本是硬编码的,因为似乎没有到最新版本的链接。
交货。这里是下载最新firefox版本的行
wget -nv -O ~/FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64"
而这里是下载特定版本的geckodriver
wget -nv -O ~/geckodriver.tar.gz "https://github.com/mozilla/geckodriver/releases/download/v0.29.1/geckodriver-v0.29.1-linux64.tar.gz"
是否总是得到最新的chromedriver和geckodriver?
检查这个要点是否有帮助,至少对于chromedriver:
version=$(curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
download_location= " http://chromedriver.storage.googleapis.com/ $version /chromedriver_linux64.zip "
rm /tmp/chromedriver_linux64.zip
wget -P /tmp $download_location
unzip /tmp/chromedriver_linux64.zip -d .
mv ./chromedriver ./chromedriver.linux
chmod u+x ./chromedriver.linux
geckodriver:
install_dir= " /usr/local/bin "
json= $( curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest )
if [[ $( uname ) == " Darwin " ]] ; then
url= $( echo " $json " | jq -r ' .assets[].browser_download_url | select(contains("maces")) ' )
elif [[ $( uname ) == " Linux " ]] ; then
url= $( echo " $json " | jq -r ' .assets[].browser_download_url | select(contains("linux64")) ' )
else
echo " can't determine OS "
exit 1
fi
curl -s -L " $url " | tar -xz
chmod +x geckodriver
sudo mv geckodriver " $install_dir "
为了避免两个结果(.tar.gz和.tar.gz)。asc文件):
https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz
https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz.asc
我需要在jq
命令的末尾添加一个新的select子句。
的例子:
curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | jq -r ' .assets[].browser_download_url | select(contains("linux64")) | select(endswith("tar.gz"))'
这只选择所需的URL (.tar.gz存档URL):
https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz