Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在iOS上使用appium查找应用程序版本_Java_Ios_Automated Tests_Appium - Fatal编程技术网

Java 如何在iOS上使用appium查找应用程序版本

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

当我启动测试时,我需要大量的调试信息:使用的设备、操作系统和测试的应用程序版本

我的问题是关于应用程序的版本

在Android上,我使用:

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,您有以下选项:

  • 在Mac上使用命令行工具,如
    defaults
    ,在Linux上使用
    plistutil
    ,并使用
    ProcessBuilder
    从Java代码中调用它
  • 使用Java库
  • 使用Java库(它包装了dd plist和Android应用程序的类似库)免责声明:我是这个工具的作者
  • 简而言之,如果你只需要iOS,我建议选择2,如果你想要Android和iOS的相同方法,我建议选择3

    公元1年

    这取决于平台,因此并不理想(IMO)。如果您只针对一个平台来执行测试,或者不介意维护多个平台,也不介意安装一些附加工具,那么这很好

    这些是用于检索版本信息的命令。同样,您也可以从应用程序包中查询其他元数据

    Mac操作系统:

    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