Reputation: 31
I wrote some script in Linux which adapts CHROME_DRIVER_VERSION and CHROME_VERSION before running e2e, but I found that this script doesn't work for mac\windows because I use google-chrome --product-version
command.
this is my script:
CHROME_VERSION=$(google-chrome --product-version | grep -oE "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,5}")
CHROME_DRIVER_VERSION=$(curl "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}")
webdriver-manager clean && webdriver-manager update --versions.chrome $CHROME_DRIVER_VERSION
how do i convert it to run with mac os and run it as .exe?
i wanna do something like this:
case "$(uname -s)" in
Darwin)
CHROME_VERSION= expression
;;
Linux)
CHROME_VERSION=$(google-chrome --product-version | grep -oE "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,5}")
;;
*)
echo 'Other OS'
;;
esac
CHROME_DRIVER_VERSION=$(curl "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}")
webdriver-manager clean && webdriver-manager update --versions.chrome $CHROME_DRIVER_VERSION
Upvotes: 1
Views: 1420
Reputation: 21249
Use PlistBuddy
:
zrzka@hyrule ~ % /usr/libexec/PlistBuddy \
-c "Print CFBundleShortVersionString" \
/Applications/Google\ Chrome.app/Contents/Info.plist
84.0.4147.105
Add this to your script:
CHROME_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" /Applications/Google\ Chrome.app/Contents/Info.plist)
It assumes that the Google Chrome browser is installed.
Upvotes: 1