加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 17:50:34 所属栏目:百科 来源:网络整理
导读:在测试本机Objective-C应用程序时,Appium需要一个有效的.app包或.zip归档的.app包,以便与Instruments一起运行自动化. 但是我正在做一些非常错误的事情并试图创建一个有效的.app包,而Appium实际上可以在iOS模拟器中运行. 我正在用Java编写自动化并使用JUnit.
在测试本机Objective-C应用程序时,Appium需要一个有效的.app包或.zip归档的.app包,以便与Instruments一起运行自动化.

但是我正在做一些非常错误的事情并试图创建一个有效的.app包,而Appium实际上可以在iOS模拟器中运行.

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

目前,在Xcode中,我正在为“iOS设备”生成.xarchive文件,然后使用Xcode Organizer向我显示.xarchive文件的放置位置.一旦我找到这个档案,我就会使用“显示包内容”深入查看.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'

当我然后使用相同的test.app包并压缩它,然后像这样更改代码:

cap.setCapability("app","/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/Story/Products/Applications/test.app.zip");

我在Appium控制台中收到以下错误:

error: Failed to start an Appium session,stat '/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/test.app.zip'

然后当我在服务器(Ubuntu,Apache)上放置相同的压缩test.app存档并更改我的代码时:

cap.setCapability("app","http://10.xxx.xxx.100/var/www/myGitRepo/myProject/test.app.zip");

我在Appium控制台中得到以下错误对话框:

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模拟器上正确安装我的应用程序(我已经可以这样做了)然后让Appium告诉Instruments启动已经安装的应用程序?如果是这样,如何在我的功能代码块中指定?

我是否需要生成扩展名为.ipa的包,然后做一些喜欢它的东西?

显然,在Xcode中构建.app包时,我总是很新,并且可以真正使用这里的好灵魂提供的任何帮助.如果我能让Appium在iOS模拟器上启动fricken应用程序,我就是黄金!

提前感谢您的任何反馈!

沃尔夫

解决方法

>建立你的项目. >单击管理器图标(右上角). >单击“派生数据”目录旁边的箭头(类似?/ Library / Developer / Xcode / DerivedData / YouApp-ajsnkjasngjkans). > Finder将在派生数据目录中打开,转到/ Build / Products / Debug-iphonesimulator. >有,你找到了你的.app文件.点赞它并享受.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读