【问题标题】:get chrome version in terminal in mac在mac的终端中获取chrome版本
【发布时间】:2020-08-04 14:35:34
【问题描述】:

我在运行 e2e 之前在 Linux 中编写了一些适应 CHROME_DRIVER_VERSION 和 CHROME_VERSION 的脚本,但是我发现这个脚本不适用于 mac\windows,因为我使用了google-chrome --product-version 命令。 这是我的脚本:

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

如何将其转换为使用 mac os 运行并作为 .exe 运行?

我想做这样的事情:

   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

【问题讨论】:

    标签: linux bash macos shell google-chrome


    【解决方案1】:

    使用PlistBuddy:

    zrzka@hyrule ~ % /usr/libexec/PlistBuddy \
      -c "Print CFBundleShortVersionString" \
      /Applications/Google\ Chrome.app/Contents/Info.plist
    84.0.4147.105
    

    将此添加到您的脚本中:

    CHROME_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" /Applications/Google\ Chrome.app/Contents/Info.plist)
    

    假定已安装 Google Chrome 浏览器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-07
      • 1970-01-01
      • 2013-03-15
      • 2020-08-30
      • 1970-01-01
      • 2020-09-26
      • 2021-12-15
      • 2013-11-20
      相关资源
      最近更新 更多