How to create a valid .app or .zip archive for iOS automation using Appium?

When testing native Objective-C applications, Appium requires a valid .app package or a .zip-archived .app package to run automation with tools.

But I'm doing something terribly wrong and running against a brick wall, trying to just CREATE a valid .app package that Appium can actually run on the iOS emulator.

I am writing my automation in Java and using JUnit.

Currently, in Xcode, I am creating a .xarchive file for an "iOS device" and then using Xcode Organizer to show me where the .xarchive file was placed. As soon as I find this archive, I use the “contents of the show package” to expand it .xarchive until I find the test.app package in xarchive, which is grayed out and shows a circle / slash through the .app icon (yes, I know, Problems...). I pull the test.app package out of .xarchive and then put it in a directory with 777 write permissions.

In my Java code (Maven project using the Eclipse IDE) I write these features, providing the full path to the test.app package:

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... } } 

When I run this code, regardless of whether the "application path" was also added to the test.app package (as it was done above) on the Appium interface, I get the following error in the Appium console:

 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' 

When I then take the same test.app package and zip it up, then change the code like this:

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

The following error appears in the Appium console:

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

And then, when I host the same zipped test.app archive on the server (Ubuntu, Apache) and change my code like this:

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

The following error dialog box appears in the Appium console:

 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? 

What the hell am I doing wrong?

Is there a way to just install my application correctly on an iOS emulator (I can already do it perfectly) and then Appium will tell Tools to launch an already installed application? If so, how will this be indicated in my block of opportunity code?

Do I need to create a package with the .ipa extension and then do something with this?

Obviously, I'm a complete novice when it comes to building .app packages in Xcode and can really use any help that good souls can provide. If I can just get Appium to run the fricken app in iOS Emulator, I'm golden!

Thanks in advance for any feedback!

Wulf

+4
source share
3 answers
  • Create a project.
  • Click on the organizer icon (top right).
  • Click on the arrow next to the Derived Data directory (something like ~ / Library / Developer / Xcode / DerivedData / YouApp-ajsnkjasngjkans).
  • Finder opens in the derived data directory, go to / Build / Products / Debug -iphonesimulator.
  • Yes, you found your .app file. Call appium to it and enjoy.
+3
source

The easiest way I found this work is by:

  • Build and run the simulator app in xcode.
  • Go to “Products” in the left navigation bar in Xcode and click “Control” (right-click) on YourApp.app and select “Show in Finder”. (This is the .app you want to use)
  • If you want .zip just right-click (right-click) in the application and select "Compress YourApp.app"
+2
source

You can also create an application in the terminal:

 xcodebuild VALID_ARCHS="i386" -sdk iphonesimulator -configuration your_configuration -target your_target 
+1
source

Source: https://habr.com/ru/post/1484248/


All Articles