0

I am working on creating tests for a macOS application using Appium for Mac. I found that Appium doesn't return any information regarding the installation status of the application (is it exist?) on the device, but I have to be sure that the application exist before running tests.

How can I check that it is?

Mike Collins
  • 4,108
  • 1
  • 21
  • 28

3 Answers3

1

Assuming you're using C# (you used the tag):

File.Exists(path)

Since an application is most likely a bundle and appears as a folder to the OS, you'd want:

Directory.Exists(path)

If those return false, halt execution.

Mike Collins
  • 4,108
  • 1
  • 21
  • 28
  • Hi. This way works only for applications that were installed to the "Application" folder. If you are working on another applications and run it from Xcode or VS -> it will contained only in "bin" folder BUT Appium will find it. – Mykyta Bondarenko Feb 12 '18 at 09:04
  • A path is a path. Where is your application residing and what path are you using? Perhaps you're trying to use a relative path when you should be using an absolute one? – Mike Collins Feb 12 '18 at 17:15
  • In my case I have only application name. That's all. I need to check is application installed and if no - build it. – Mykyta Bondarenko Feb 13 '18 at 10:00
  • 1
    Ah, I understand. You’re looking to see if the app is installed on the device. My answer assumed you were looking for a built application on your machine. – Mike Collins Feb 13 '18 at 18:54
  • I maintain this is still the proper way to do this. Appium handles installation and reports success/failure itself. The only way building the application would resolve an install failure is if you catch it before building your Appium driver. Run the code above, build if it's not found, let Appium do the rest (start the driver). – Mike Collins Feb 14 '18 at 15:15
1

Checking if the app is installed check is done by Appium internally and you don't have to worry about this. Appium will install the app for you if it wasn't installed and you can also tell Appium to reinstall the app for you every time you trigger a session by using the fullReset capability.

Hassan Radi
  • 936
  • 10
  • 22
  • How does Appium install my application if I should build it before? If I will pass application name to Appium but my application isn't installed -> nothing occurres - it will continue work and fail when I ask it some UI element. So I need to check this state before and build my project before if need. – Mykyta Bondarenko Feb 13 '18 at 09:58
  • @MykytaBondarenko You are supposed to build your app and provide the appropriate apk/ipa to Appium using the `app` capability and Appium will take it from there. – Hassan Radi Feb 13 '18 at 10:44
  • Yes, but I think that I shouldn't build in vain it if it's already exist – Mykyta Bondarenko Feb 13 '18 at 10:58
  • 1. Is .app exist? 1.1. Yes -> pass param to appium 1.2 No -> build project -> pass param to appium – Mykyta Bondarenko Feb 13 '18 at 10:59
  • 1
    Simply because that's not how Appium works. You are testing the app as an end user (black-box approach) when using Appium and you are supposed to have the app built. You can try Espresso if you want more control and a white-box approach. – Hassan Radi Feb 13 '18 at 11:10
  • Does it (Espresso) work only for Android? And I understand that's not clear to do it like I am but I need to know is app installed already. At the first I think that Appium should return some error or invoke event if app doesn't exist. At the second - I couldn't find any way to get info how the Appium gets information of app (when it is located in "bin" folder) – Mykyta Bondarenko Feb 13 '18 at 11:20
  • Espresso is only for Android. You can also try this appium method (I haven't tried it myself) `driver.isAppInstalled("appBundleID") ` Here is a link that describes how you can do this for both Android/iOS using other commands https://discuss.appium.io/t/how-to-use-isappinstalled-string-bundleid-method/7919 – Hassan Radi Feb 13 '18 at 11:26
  • Unfortunately this functional doesn't exist for mac application :( – Mykyta Bondarenko Feb 14 '18 at 11:47
  • It is part of the Java API https://appium.github.io/java-client/io/appium/java_client/InteractsWithApps.html#isAppInstalled-java.lang.String- – Hassan Radi Feb 14 '18 at 12:46
  • Unfortunately I didn't find how to do this via Appium, so I use the Terminal now. Thanks! – Mykyta Bondarenko Feb 16 '18 at 11:49
0

Finally I found an answer to the question. If you want to check if an application exists -> run the next line in the Terminal:

mdfind -name {application_name}.app