当测试本机Objective-C应用程序时,Appium需要一个有效的。app包,或者一个。zip存档的。app包,以便在with Instruments上运行自动化。
但是我做了一些可怕的错误,并试图创建一个有效的。app包,Appium可以在iOS模拟器中实际运行碰壁。
我正在写我的自动化在Java和使用JUnit。
目前,在Xcode中,我正在为"iOS设备"生成一个。xarchive文件,然后使用Xcode Organizer显示。xarchive文件的位置。找到这个存档后,我使用"show package contents"向下钻取.xarchive,直到找到测试。在xarchive中的app包,它是灰色的,并通过。app图标显示一个圆圈/斜杠(是的,我知道,麻烦…)。我做了测试。从.xarchive中取出App包,然后将其放在具有777写权限的目录中。
在我的Java代码(使用Eclipse IDE的Maven项目)中,我编写了这样的功能,给出了测试的完整路径。应用程序包:
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...
}
}
在运行此代码时,是否也给了"应用程序路径"进行测试。app包(如上所述)在Appium界面上,我在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'
当我做同样的测试时。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, err was: Error: ENOENT, stat '/Users/wulf/Library/Developer/Xcode/Archives/2013-05-31/test.app.zip'
然后当我放置相同的压缩测试时。app存档在服务器上(Ubuntu, Apache),并更改我的代码,像这样:
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模拟器上启动这款有趣的应用,我就成功了!
提前感谢任何反馈!
沃尔夫我发现最简单的方法是:
- 在xcode中为模拟器构建并运行应用程序。
- 在Xcode的左侧导航中找到Products,然后右键单击YourApp。应用程序,并选择显示在Finder。(这是你要使用的。app)
- 如果你想要一个。zip文件,只需右键单击应用程序并选择"Compress YourApp.app"
- 创建项目
- 点击组织者图标(右上)。
- 点击"派生数据"目录旁边的箭头(类似于~/Library/Developer/Xcode/DerivedData/YouApp-ajsnkjasngjkans)查找器将在派生数据目录中打开,进入/Build/Products/debug -iphone模拟器。你找到了你的。app文件。指向它并享受它。
你也可以在终端构建应用程序:
xcodebuild VALID_ARCHS="i386" -sdk iphonesimulator -configuration your_configuration -target your_target