Java 如何在iOS上使用appium查找应用程序版本
当我启动测试时,我需要大量的调试信息:使用的设备、操作系统和测试的应用程序版本 我的问题是关于应用程序的版本 在Android上,我使用:Java 如何在iOS上使用appium查找应用程序版本,java,ios,automated-tests,appium,Java,Ios,Automated Tests,Appium,当我启动测试时,我需要大量的调试信息:使用的设备、操作系统和测试的应用程序版本 我的问题是关于应用程序的版本 在Android上,我使用: String line=“adb-s”+udid+“shell dumpsys包”; Runtime.getRuntime().exec(行); 在这之后,搜索包名和版本名就很容易了 但是如何在iOS上找到相同的信息呢?我没有找到任何包含应用程序信息的文档。(显然,adb与iphone不兼容)你可以试试这个。如果您正在使用*.app,您可以尝试使用此com
String line=“adb-s”+udid+“shell dumpsys包”;
Runtime.getRuntime().exec(行);
在这之后,搜索包名和版本名就很容易了
但是如何在iOS上找到相同的信息呢?我没有找到任何包含应用程序信息的文档。(显然,adb与iphone不兼容)你可以试试这个。如果您正在使用*.app,您可以尝试使用此comand: 或ipa“ipa/payload/NAME.app/Info.plist” TL;DR 查看摘要
对于iOS,您有以下选项:
defaults
,在Linux上使用plistutil
,并使用ProcessBuilder
从Java代码中调用它defaults read /path/test.app/Info CFBundleShortVersionString
defaults read /path/test.app/Info CFBundleVersion
Linux:
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleShortVersionString']/following-sibling::string[1]/text()" -
plistutil -i /path/test.app/Info | xmllint --xpath "//key[text()='CFBundleVersion']/following-sibling::string[1]/text()" -
这种方法可能最适用于shell脚本(例如,在CI管道中)
将其集成到Java程序中看起来是这样的(请注意,如果您决定使用它,可能需要添加一些额外的错误处理):
我为此做了PoC。虽然这样做很好,而且不需要任何额外的Java库,但我还是推荐其他选项之一
公元2年
将dd list JAR文件添加到类路径中。例如,对于Maven:
<properties>
<dd.plist.version>1.21</dd.plist.version>
</properties>
<dependencies>
<dependency>
<groupId>com.googlecode.plist</groupId>
<artifactId>dd-plist</artifactId>
<version>${dd.plist.version}</version>
</dependency>
</depdencies>
公元3年
将justtestlah mobile tools
JAR文件添加到类路径中。对于Maven:
<properties>
<justtestlah.version>1.3.2</justtestlah.version>
</properties>
<dependencies>
<dependency>
<groupId>io.github.martinschneider</groupId>
<artifactId>justtestlah-mobile-tools</artifactId>
<version>${justtestlah.version}</version>
</dependency>
</depdencies>
最后一个的附加好处是,您可以对APK、APP甚至IPA文件使用相同的代码。我想您可以使用以下命令获得应用程序版本:
ideviceinstaller -l | grep appBundleId
但首先需要使用以下命令安装ideviceinstaller:
brew install --HEAD ideviceinstaller
您是否使用Appium进行自动测试?是的,我使用Appium进行测试。我们可以使用捆绑包id或ipa文件提取应用程序版本吗?是的,您可以从ipa文件接收版本信息。请查看文章中的分步指南:。简而言之,您需要解压缩IPA文件(
unzip-q/path/test.IPA-d/tmp/IPA
),然后步骤与应用程序相同。感谢您的回复。我可以使用ideviceinstaller-l | grep“packageName”
<properties>
<justtestlah.version>1.3.2</justtestlah.version>
</properties>
<dependencies>
<dependency>
<groupId>io.github.martinschneider</groupId>
<artifactId>justtestlah-mobile-tools</artifactId>
<version>${justtestlah.version}</version>
</dependency>
</depdencies>
ApplicationInfo appInfo = new ApplicationInfoService().getAppInfo(appPath);
String versionName = appInfo.getVersionName();
String versionCode = appInfo.getVersionCode();
String applicationName = appInfo.getApplicationName();
ideviceinstaller -l | grep appBundleId
brew install --HEAD ideviceinstaller