linux 如何始终下载最新版本的chromedriver和geckodriver?

bis0qfac  于 2023-08-03  发布在  Linux
关注(0)|答案(2)|浏览(235)

对我们的线人进行自动化测试。目前,我们正在检索最新版本的Chrome和Firefox作为我们设置的一部分,但是,我们使用的chromedriver和geckodriver版本是硬编码的,因为似乎没有指向最新版本的链接。
Ex.这里是下载最新版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?

x9ybnkn6

x9ybnkn61#

检查this gist是否有帮助,至少对于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 "

fruv7luv

fruv7luv2#

要避免两个结果(.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

相关问题