Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.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
如何创建有效的.app或.zip存档以使用Appium自动化iOS?_Ios_Xcode_Instruments_Remotewebdriver_Appium - Fatal编程技术网

如何创建有效的.app或.zip存档以使用Appium自动化iOS?

如何创建有效的.app或.zip存档以使用Appium自动化iOS?,ios,xcode,instruments,remotewebdriver,appium,Ios,Xcode,Instruments,Remotewebdriver,Appium,在测试本机Objective-C应用程序时,Appium需要一个有效的.app包或.zip存档的.app包,以便根据仪器运行自动化 但是我做了一些非常错误的事情,并且在尝试创建一个有效的.app包时遇到了困难,Appium实际上可以在iOS模拟器中运行 我正在用Java编写自动化程序并使用JUnit 目前,在Xcode中,我正在为“iOS设备”生成一个.xarchive文件,然后使用Xcode管理器显示.xarchive文件的放置位置。找到此存档后,我将使用“show package conte

在测试本机Objective-C应用程序时,Appium需要一个有效的.app包或.zip存档的.app包,以便根据仪器运行自动化

但是我做了一些非常错误的事情,并且在尝试创建一个有效的.app包时遇到了困难,Appium实际上可以在iOS模拟器中运行

我正在用Java编写自动化程序并使用JUnit

目前,在Xcode中,我正在为“iOS设备”生成一个.xarchive文件,然后使用Xcode管理器显示.xarchive文件的放置位置。找到此存档后,我将使用“show package contents”深入到.xarchive,直到在xarchive中找到test.app包,该包变灰并在.app图标中显示一个圆圈/斜线(是的,我知道,麻烦…)。我从.xarchive中提取test.app包,然后将其放在具有777写入权限的目录中

在我的Java代码(使用Eclipse IDE的Maven项目)中,我编写了如下功能,给出了test.app包的完整路径:

package com.my.appium._webdriver_test_demo;
import java.net.URL;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class AppiumWebDriverTestBVTDemo {

    private WebDriver driver;

    @Before
    public void setup() throws Exception
    {

        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability("device", "iPhone Simulator");
        cap.setCapability("app", "/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/Test/Products/Applications/test.app");    

        driver = new RemoteWebDriver(new URL("http://localhost:4723/wd/hub"), cap);

    }   

    @After
    public void tearDown() throws Exception
    {
        //Do stuff...
    }
}
运行此代码时,无论是否已在Appium接口上为test.App包(如上所述)提供了“App path”,我都会在Appium控制台中收到以下错误:

error: Could not parse plist file at /Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/Story/Products/Applications/test.app/Info.plist

error: Failed to start an Appium session, err was: Error: ENOENT, open '/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/Story/Products/Applications/test.app/Info.plist'
error: Failed to start an Appium session, err was: Error: ENOENT, stat '/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/test.app.zip'
error: Test zip archive threw error Error: Command failed: 

error: Stderr: Archive:  /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip or
        /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip.zip, and cannot find /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip.ZIP, period.

error: Stdout: 
error: Failed to start an Appium session, err was: Error testing zip archive, are you sure this is a zip file?
当我使用相同的test.app包并将其压缩,然后像这样更改代码时:

cap.setCapability("app", "/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/Story/Products/Applications/test.app.zip");
cap.setCapability("app", "http://10.xxx.xxx.100/var/www/myGitRepo/myProject/test.app.zip");
我在Appium控制台中遇到以下错误:

error: Could not parse plist file at /Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/Story/Products/Applications/test.app/Info.plist

error: Failed to start an Appium session, err was: Error: ENOENT, open '/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/Story/Products/Applications/test.app/Info.plist'
error: Failed to start an Appium session, err was: Error: ENOENT, stat '/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/test.app.zip'
error: Test zip archive threw error Error: Command failed: 

error: Stderr: Archive:  /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip or
        /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip.zip, and cannot find /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip.ZIP, period.

error: Stdout: 
error: Failed to start an Appium session, err was: Error testing zip archive, are you sure this is a zip file?
然后,当我在服务器(Ubuntu、Apache)上放置相同的zip test.app归档文件并更改代码时,如下所示:

cap.setCapability("app", "/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/Story/Products/Applications/test.app.zip");
cap.setCapability("app", "http://10.xxx.xxx.100/var/www/myGitRepo/myProject/test.app.zip");
我在Appium控制台中看到以下错误对话框:

error: Could not parse plist file at /Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/Story/Products/Applications/test.app/Info.plist

error: Failed to start an Appium session, err was: Error: ENOENT, open '/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/Story/Products/Applications/test.app/Info.plist'
error: Failed to start an Appium session, err was: Error: ENOENT, stat '/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/test.app.zip'
error: Test zip archive threw error Error: Command failed: 

error: Stderr: Archive:  /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip or
        /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip.zip, and cannot find /var/folders/gg/2_0flj7s51nd88kbtlwmm1qjxw981t/T/appium-app11353-39508-t2rmzq.zip.ZIP, period.

error: Stdout: 
error: Failed to start an Appium session, err was: Error testing zip archive, are you sure this is a zip file?
我到底做错了什么

有没有办法在iOS emulator上正确安装我的应用程序(我已经可以很好地完成),然后让Appium告诉Instruments启动已经安装的应用程序?如果是这样,如何在我的功能代码块中指定这一点

我是否需要生成一个扩展名为.ipa的包,然后用它做一些有趣的事情

显然,在Xcode中构建应用程序包时,我完全是个新手,我真的可以使用这里的善良灵魂所能提供的任何帮助。如果我能让Appium在iOS模拟器上启动fricken应用程序,我就是金牌

提前感谢您的反馈


Wulf

我发现最简单的方法是:

  • 在xcode中为模拟器构建并运行应用程序
  • 转到Xcode左侧导航中的产品,并在YourApp.app上控制单击(右键单击),然后选择Show in Finder。(这是您要使用的.app)
  • 如果您想要一个.zip控件,只需在应用程序上单击(右键单击)并选择“压缩您的应用程序.app”
  • 构建您的项目
  • 单击组织者图标(右上角)
  • 单击“派生数据”目录旁边的箭头(类似~/Library/Developer/Xcode/DerivedData/YouApp ajsnkjasngjkans)
  • Finder将在派生数据目录中打开,转到/Build/Products/Debug iphonesimulator
  • 有,你找到了你的.app文件。指向它并享受它

  • 您还可以在终端中构建应用程序:

    xcodebuild VALID_ARCHS="i386" -sdk iphonesimulator -configuration your_configuration -target your_target
    
    看见