首页 > 解决方案 > 如何通过自动化脚本查找已安装的应用程序版本?

问题描述

我需要查找安装在移动设备中的应用程序版本,如果版本不是最新版本,则安装最新版本。在这里我如何自动查找已安装的应用程序版本?我正在使用 appium 和 selenium 来自动化我的脚本。

标签: seleniumappium

解决方案


如果您想查找 android 应用程序版本,您可以使用 shell 命令来完成

String cmd = "adb shell dumpsys package your.app.package.name.here |grep versionName";
Process process = null;
try {
     process = Runtime.getRuntime().exec(cmd);
     String appVersion = new BufferedReader(new InputStreamReader(process.getInputStream())).readLine();
        System.out.println("appVersion = "+appVersion);
    } catch (IOException e) {
        e.printStackTrace();
    }

有关更多信息,请查看此stackoverflow 问题


推荐阅读