Appium path for excel file, and .app file

Hello,

I know that usually when reading from an excel file in appium we can give the excel file path from desktop…and similarly we can set the capabilities for the .app file path from desktop.

However, if I check in code to my version control source code system (GitHub) so that we can run the tests from Jenkins…we would want to make the scripts flexible enough and perhaps not have the file paths as my local desktop. How to best tackle this so that anyone can run the tests from jenkins, as in what can be done with the paths ?

Use a relative path:

https://www.google.com/#q=relative+path+command+line

Thanks for the link to the article. The Jenkins box is going to be a different box than my local. So lets say I have my iOS app file on my desktop, as well as some excel sheet that I need to read data from as part of tests can you tell me how it would be exactly?

Does the app file or excel sheet need to be on the In my desired capabilities my app file is in this folder on my desktop: App path: /Users/sbhatt/Desktop/Build/Products/Debug-iphonesimulator/Sample-FrontEnd.app.
Could you state how I should write it so that I can run the scrip without problems from Jenkins box ?

@wreed could you please respond ?

Sorry, didn’t know you were waiting on me. I only get in here once a day or so.

For your problem, I think the desktop is probably the worst place to store stuff. Why not have a folder in your project called ‘assets’ or something similar and then use a relative path to access it.

For example, in my project the top directory is ‘appium’ inside there I have things like, ‘node_modules’, .yml files, etc. It’s easy for me to move this to another box (such as the Jenkins server) and then address any files that are in the assets folder on a very consistent basis. ‘assets/my_excel_doc.xml’ for example.

Hope that helps.

@wreed in Eclipse under the src folder I tied to create a new File where I could add the app file under the src folder. Unfortunately it won’t let me do that…not sure why.

Are you talking about creating a Folder in the Project in eclipse ?

I always view my project folder as independent of IDE, but you may view this differently. For example, I like to be able to run my automation from the command line, but I do use an IDE for development of the tests. So to me it shouldn’t matter what tool you use to create a folder. If the IDE were giving me grief then I would just drop into a command line & ‘mkdir’. The IDE should pick the folder up (restarting would probably be reasonable). In my view you should set things up so that if you don’t like a particular IDE, or want to run things outside it you should set the project folder up to accommodate this from the beginning. The project should be organized modularly; it should also be portable. Anyone contributing to this project should be able to download the repo, use any IDE (or not), and be able to get up and running quickly.

Sorry for the rant, but my point is don’t get hung up on something like a balky IDE. Organize your framework/project so that it is easy for you to use and share with others.

@wreed, you still around to help on this? :-).

I am still struggling with this. Do I need to copy over the app into my ECLIPSE src/test/resources folder (if that helps?). Not sure how to proceed as the code I have checked in needs to be run by other members on my team. Of course they can pull the code but the app path will not be their Desktop path like I have…

if you can tell exactly what needs to go here that would be great:

  1. in the Appium GUI where it asks for path
  2. in my code where it says: capabilities.setCapability(“app”, “/Users/kbt/Desktop/Build/Products/Debug-iphoneos/TT.app”);

Thanks!

anyone else feel free to respond too please =)

Yeah, this is why I suggest a relative path in your code. You don’t have to commit the binary to your code repository, but as part of setup you would put the file in there. For example, my code looks something like this:

appium/
  spec/
  assets/
    simulators/
    real_devices/

‘spec’ directory holds all my tests, libraries, results, etc. ‘assets’ holds any files external to my code that I need for tests. So:

  1. This path would look like ‘/Users/wreed/appium/assets/simulators/my_awesome_app.app’ when testing on a Simulator. Of course you have to set this by hand.

  2. Since I believe you are doing this in Java, I’d get the current working directory:

    String currentDir = System.getProperty(“user.dir”)
    Then use that to set the capability:

    capabilities.setCapability(“app”, currentDir + “/assets/simulators/my_awesome_app.app”)
    That way this works on any system, regardless of where the testing code is.

Good luck.

@wreed I will try that out. In addition on the Appium GUI field for “App Path” what do I put there?

Thanks

I don’t use the GUI, but I tried to answer that question in ‘1’ above. You have to manually set that to whatever the path is, right?

@wreed
So I set the path in my Eclipse JAVA code to this: capabilities.setCapability(“app”, currentDir + “/Debug-iphoneos/TT.app”);

At first I was getting an error because it was saying there was no app located at “/Users/kbt/Downloads/eclipse 2/Eclipse.app/Contents/MacOSsfdsfs/Debug-iphoneos/TT.app”. Not sure why I got this error but anyway I then copied the app into that path and now my code seems to work fine after running from Eclipse. My problem however is that it directly assumed that the TT app would be in that location under Eclipse (dunno why). That then means anyone else who pulls my code and runs it on their local would have to install Eclipse…which I thought would not be necessary?

Thanks.

Wow, that’s not good. So Eclipse is starting you in it’s own directory rather than the test framework directory. I don’t use Eclipse regularly anymore so I opened it up, created a new project (/Users/wreed/java/learning) with a file ‘test.java’ that looks like this:

public class test
{
	public static void main(String[] args) {
		System.out.println(System.getProperty("user.dir"));
	}
}

Running that I get the output:

/Users/wreed/java/learning

So something must be wrong with your setup of Eclipse. I have no idea what that might be.

OK. I just ran that same piece of code in Eclipse too and I got this output:
/Users/kbt/git/IOS_Automation/SmokeTest

If it helps the original error also said the following:
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Bad app: /Applications/eclipse 2/Eclipse.app/Contents/MacOSohho/Debug-iphoneos/TT.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/eclipse 2/Eclipse.app/Contents/MacOSohho/Debug-iphoneos/TT.app’) (WARNING: The server did not provide any stacktrace information)

Lo and Behold! I got it to work by copying the Appium app into the same directory where my Project is…works for now!

Thank you Sir…will let you know if I hit any other roadblocks =)