Appium looking for test app in its own installation directory when running from windows to Mac machine

So the problem is appium is looking in its install dir for some reason then adding my apps path to that. The error is reads…

Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Bad app: /Applications/Appium.app/Contents/Resources/node_modules/appium/C:\Users\xxx\workspace\AndroidTesting\Users\adminqa\Desktop\xxx.app. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat ‘/Applications/Appium.app/Contents/Resources/node_modules/appium/C:\Users\xxx\workspace\AndroidTesting\Users\adminqa\Desktop\xxx.app’) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 145 milliseconds

Now if i put the file in the location its already looking into it work… or if i run this on the local machine it looks in the correction location. i replaces sensitive info with xxx, i can confirm there are NO spaces before i replaced the names with ‘xxx’ i heard that can cause issues.

File classpathRoot = new File(System.getProperty(“user.dir”));
File appDir = new File(classpathRoot,“Users/adminqa/Desktop/”);
File app = new File(appDir, “Flights.app”);

capabilities = new DesiredCapabilities();
capabilities.setCapability(“deviceName”, “iPhone Simulator”);
capabilities.setCapability(“platformName”, “iOS” );
capabilities.setCapability(“deviceName”, “”);
capabilities.setCapability(“platformVersion”, “8.4”);
capabilities.setCapability(“app”, app.getAbsolutePath());

UPDATE:
so apparently this works… but not sure why the other way wont.

capabilities.setCapability(“app”, “/Users/adminqa/Desktop/xxx.app”);

I’m still not quite sure what’s going on from your logs, because it looks like you’re giving Appium a Windows file path on an OS X system. Let’s clear something up first. What are you running on: Windows, OS X, or Linux?

Im running on a windows machine, which is connecting to a Mac machine. The IOS app is on the mac machine too.

This is a relative path:

This is an absolute path:

So if you give a relative path it will try to find that relative to it’s own path.

I see now. You can try your original code, but you can debug it by printing out what the file path is with a print statement before you add it to the DesiredCapabilities object.

File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot,"Users/adminqa/Desktop/");
File app = new File(appDir, "Flights.app");
....
System.out.println(app.getAbsolutePath());
....

The reason why these lines are giving a bad path to Appium is because…

  1. System.getProperty(“user.dir”) returns the working directory of the Java process running on your client Windows machine. This is a system- and process-dependent value, so it should be expected that whatever value is here will not be easily translated to a Unix system.
  2. The File class is different among implementations of Java for different systems. The way File can resolve file paths on Windows is different from how paths can be resolved on Unix machines (since Windows has a thing with C:, D:, etc. drives, while Unix systems do not). File probably should not be used here.

I recommend sticking with your second way of specifying the app. The path you give in your second example is an absolute path that makes sense on your server machine. (If you want to be able to change which app archive gets used by Appium, you can specify an HTTP URL pointing to some app sitting on a network, but you’ll have to put your app somewhere where Appium can download it)

Ohh ok i dont use unix that much and have little knowledge of things like this.
Thanks so much for your replies, all great info.

You’re welcome! Thanks for asking!