Appium iOS tests not running - ios

I'm attempting to setup an automated testing environment using appium, however I'm running into trouble. The issue I'm seeing is that appium is extracting the zip containing the .app directory, but then claiming that it can't find the .app. My platform is mac. The exact error is below:
info: Unzipping /var/folders/0s/0kz_6kb13f35wxwjxkff9sdw0000gn/T/appium-app113922-2258-1ap6o7i.zip
info: Testing zip archive: /var/folders/0s/0kz_6kb13f35wxwjxkff9sdw0000gn/T/appium-app113922-2258-1ap6o7i.zip
info: Zip archive tested clean
info: Unzip successful
info: Got configuration error, not starting session
error: Failed to start an Appium session, err was: App zip unzipped OK, but we couldn't find a .app bundle in it. Make sure your archive contains the .app package and nothing else
info: Responding to client with error: {"status":6,"value":{"message":"A session is either terminated or not started","origValue":"App zip unzipped OK, but we couldn't find a .app bundle in it. Make sure your archive contains the .app package and nothing else"},"sessionId":null}
I'm not sure if I'm doing something wrong in my code, below is the contents of my setup() method (which is basically copied from the official example).
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device", "8b0949a1d3fe5d7283cc46ca5470acd67d6c5d7b");
File app = new File("/Users/user/path/to/zip");
capabilities.setCapability("version", "7.0");
capabilities.setCapability("app", app.getAbsolutePath());
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

Things to consider:
Your .zip should contain only the .app
The .app should be built in XCode with the same dev certificate that is used on the device (iPhone)
For me it worked this way: I built an .app from source in XCode and uploaded to the device. Then in Appium I just specified the Bundle ID (in XCode Window>Organizer>Apps if I remember it right) of the app.

For anyone with a similar problem: I fixed this issue by specifying the .app file but specifying the UDID of the device at the command line when running appium instead of in the test code. I think that specifying the 'device' capability causes an error (possibly makes appium think that it's android testing, despite writing out that it's looking for a .app)

Related

How to Install .ipa File on XCode iOS Simulator

I have downloaded an .ipa file from an iOS developer for our project.
I need to test the app on my simulator because I don't have a physical device, but I don't know how to.
how to install the .ipa file to XCode iOS Simulator? I have been read the difference between emulator and simulator, which the .ipa only able installed on real device and emulator while the .app only able installed on simulator. The emulator also mimic the real device's hardware and software while simulator only mimic the software and interface. If those differences above are true, does anyone know how to convert the .ipa to working .app file? I have been tried changed the .ipa to .zip by rename it then extract it and last, drag and drop the .app file (in the payload folder after extracted) to my simulator but failed, the message is "Please update the app". I also tried the command xcrun simctl install but failed. Currently, I am using the Mac with Big Sur and XCode 12. I can't download the project because the project size is very big and my internet too slow for download it, Thank you all
Since you have the ability to run the simulator, You have the ability to have Xcode installed.
Rather than have the developer send you the IPA file, you could get access to the source code for your project (usually this is on a Git service provider) download the source and build the app to the simulator directly.
In a well set up project it shouldn't be hard to clone the repository, maybe run some configuration, then open Xcode and build to the simulator
I have the same problem, and refer to that link before. it seems noway but to buy an iphone test device...

Unable to build app for iOS, "unable to write module session file Session.modulevalidation No such file or directory"

yesterday I was working fine with Flutter, now i'm facing this issue and I already search everywhere for a solution but no success.
When I run:
flutter run
The build process starts and when its about to finish the error below is shown:
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Xcode build done. 12.3s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
error: unable to write module session file at '/Users/hencke/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation': fopen(/Users/hencke/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation, wb): No such file or directory (2)
note: Using new build system
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.
Exited (sigterm)
Looks like the process is trying to open this file Session.modulevalidation for writing, but this file really does not exist in that folder. And I don't know what to do.
Things that I already tried:
Reinstalling xcode
flutter clean
Clone my project again in another folder and try to build, but same error
Created a new flutter dummy project and tried to build, still same error
Rebooting machine several times
Give permissions to Staff to the DerivedData and ModuleCache.noindex folders
Deleted the DerivedData within hope that xcode build will recreate all the files needed, but, it created everything again but not that particular file.
So that's it, If any blessed human know how to 'recreate', or reset, clear some cache, I would be very thankful.
Before running your project, check everything is checked when running:
flutter doctor
and also make sure at least a device is connected or open iOS simulator first. You can check if flutter is successfully connected to the device by:
flutter devices
when you make sure that flutter detect your device or the simulator, then run your application by:
flutter run
After hours I finally found the solution as it follows:
Without any hope I opened my flutter project with Xcode, and then tried to build the Runner target from there, same error.
Then, I was browsing the Xcode preferences and something caught my attention, on Locations section I found something about DerivedData location, it was set as Default. So, I changed from Default to Custom location and I set to a new folder on my home directory:
Then immediately Xcode created the entire DerivedData/ModuleCache.noindex folder and with them, the Session.modulevalidation file as well.
Then I closed Xcode and tried flutter run again, and it was successfully build!
I'll let this answer to those who may come here for help.

Unable to launch app on IOS Simulator - WebDriver Agent error

I have installed Appium and XCode and am trying to launch an app on the simulator. The app works when I open the simulator manually and click on the app.
My capabilities look as follows:
File app = new File ("/Users/me/Desktop/myapp.app");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("deviceName", "iPhone 8");
capabilities.setCapability("automationName", "XCUITest");
capabilities.setCapability("app", app.getAbsolutePath());
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
The error I get is:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Unable to launch WebDriverAgent because of xcodebuild failure: "Command 'Scripts/bootstrap.sh -d' exited with code 1". (WARNING: The server did not provide any stacktrace information)
I followed the instructions given in the answer to this question:
Unable to launch ipa file in IOS 10 real Device using appium 1.6.0
When I build the WebDriverAgent through XCode, it builds without any problems, but as soon as I try to launch through IntelliJ or Appium Desktop, it gives me that error.
So I eventually managed to get it working, here are some of the errors that I encountered and how I fixed them:
Unable to launch WebDriverAgent because of xcodebuild failure: "Command 'Scripts/bootstrap.sh -d' exited with code 1
Solution: looking at the Appium server log, I noticed that it was unable to write to a directory. The problem was that my Appium app was sitting in Downloads. Once I moved it to Applications, this problem was fixed.
XCode build failed with exit code 65
Solution: the problem here was with my Provisioning Profiles (I opened the app in XCode and went to the General tab to see these).
I had created a personal apple account, but I didn't have the certificates needed to run the app. I had to get one of our iOS developers to invite me to their team, downloaded certificates and then ticked the "Automatically manage signing" check box -- there were a couple of other steps with the certificates that I can't remember.
It was connecting to the simulator, it launched WebDriverManager, but then wouldn't launch my app (it just hung).
Solution: I had made a mistake in my capabilities, I had it set as:
capabilities.setCapability("bundleId", "com.facebook.WebDriverAgentLib");
Which was the bundleID for WebDriverAgent, I updated it with the bundleID for my app:
capabilities.setCapability("bundleId", "myapp");
(Bundle ID can be found by going to the app in finder, right clicking and selecting "Show Package Contents". Open the "Info.plist" file and there you'll find the Bundle ID for the app.

How to get an iOS app build for appium testing?

I wanted to setup iOS testing on simulator on my MacBook-pro. Im using appium 1.6 and Xcode 8 and iOS 10.1 as simulator OS. I ran my appium server and set the desired capabilities and used an .ipa from the app store and it crashes on launch while doing an inspect on appium. Is it happening because i don't have a app signed for development? what are the requirements for the app to be tested for using? Do i need signed apps to be used for testing on simulator too ?
You can create a .app file useing the belowing instruction:
1- Go to:
xcode > File > New Project > (select ios at top bar) select Tabbed Application > click Next > give project name and select swift as language and complete process.
2- Open the project and run it. After running the app in the simulator, you will find the project .app file in the product folder (expand your project in xcode > product.
you can use this .app file for your appium test.
3- You can also get a lot of free .xcode project on the web. download this project, open the .xcodeproj or .xcworkspace file in xcode and run it. you will find the .app file in the product folder
if you want to run your ios app in the simulator, you need a .app file, not .ipa file. The .ipa file runs on the device. Try to generate a .app file for simulator.
Yes, you need apps to be signed with a developer provisiioning profile. You can use the iresign to do it. you should input your ipa file developer provisioning file(contact your dev) and click resign. It will output the resigned app
The same dev provisioning file, dev certificate should be installed in your mac from where you run your scripts.
Note: you cannot run .ipa on simulators. you need .app version of the app , for which you need to contact the developer too

Appium iOS Simulator Setup error

I have a .app file that I copied to my mac in a local directory (Ex: /appium/test.app) and I pointed appium to the .app file. I'm getting the following error when running in the simulator:
Could not save new Info.plist
Error: ENOTDIR, not a directory
Can any one resolve my issue? Correct me if i am doing any fundamental wrong.
I've gotten that error if I start the Appium server via the Mac App and point it at an .app directory in the Settings of the app.
You should try running Appium from the command line.

Resources