In the last article, we learnt about how Appium is used to create automated testing for mobile devices. It’s a hugely popular framework, and for good reason too. It’s very powerful.
Unlike Selenium, it’s not quite as simple as downloading a Nuget package and writing code almost straight away. There is a small amount of setup that is required, which will differ depending on the platform you’re trying to automate. In today’s example, we’re going to be concentrating on Android and all the tools you need to get going.
The first thing we need to do is to install a few prerequisites that allow us to work with Appium, so before you get started with the rest of this article, ensure you have the following installed on your machine:
– Java SDK
– Android SDK (installed to the default location)
– Create a Virtual Device with Android Device Manager
– Appium Desktop
Appium can be installed from the command line but for now, from an ease of setup as well as being more user-friendly while we learn, we’re going to use the desktop application. This is great for an easy install, but also a lot easier to use when we’re trying to get locators later on.
Once all the above has been set up, we’re ready to start automating Android apps. However, there’s one small problem…although you may know the app you want to automate by name, we can’t just tell our test that we want to automate Instagram or Facebook. We need to know the technical name that Appium will recognise and use. In the case of Android, this is known as the package name. If you haven’t heard that term before, then don’t panic. Finding out our package name is a simple process, and you already have the tools to do it thanks to the setup you did for the prerequisites.
To find the package name, we’re going to use the ‘
– Unlock your Android device while connected to your computer via USB.
– Open a new Command Prompt and run the ‘
– Run ‘
– Open the app that you intend to automate. For this example, let’s use something that every Android device will have, the Play store.
– With the Play store open, run the command ‘
– The package name will be in the following format ‘com.android.packagename’. In this example of using the Play store, it would be ‘com.android.vending’
And that’s it, you now have the package name required to begin creating automated tests. But like Selenium, you’re going to need to know how to get locators for elements in your Android app. As mentioned earlier, we’re going to be using a simple to use