logo logo

Launch Appium Automation Tests in Under 10 Minutes

main post image

Appium has become almost synonymous with mobile test automation, as it’s the most popular tool for testing mobile apps. And why shouldn’t it be? It’s free, open-source, it’s cross-platform, which means it can be used for native, hybrid, and web applications, on Android and iOS. It can be installed on any operating system, and it supports many programming languages, including Java, C#, Python, JavaScript, and the list goes on. And now that Appium version 2.0 is available (for the moment in beta), you should definitely get on board the mobile automated testing train 🚊 So if you’re convinced, but not sure where to get started with Appium automation tests, let me show you how TestProject can help you create your first project with minimum effort.

🚀 Kick-off powerful mobile test automation without limitations 🚀
GET YOUR FREE ACCOUNT TODAY

Table of Contents 

  1. Getting started with TestProject
  2. Preparing the device
    1. Installing the apk
  3. The first Appium automation tests
    1. Creating the test project
    2. Recording the test
    3. Adding validations to the test
    4. Viewing reports
    5. Next tests
    6. Generating the code
  4. Conclusions

Getting started with TestProject

TestProject is a very versatile tool that can help your testing efforts in many ways. It works for both web and mobile apps, or you can use it even for API testing. What makes TestProject so great is that it is a single SDK built on top of the Selenium and Appium APIs, allowing test creation for cross-platform web and mobile tests, including support for all web browsers, for iOS and Android devices, as well as iOS on Windows. It also includes automatic reporting both for the recorded tests and for the coded tests.

To get started, you can use it as a codeless test automation tool, or you can use the OpenSDK (which BTW is available for Java, C#, and Python), to code your own tests. Or why not have the best of both worlds and generate the code from recorded tests? 🤩

Unlock Mobile Automation Testing in Under 10 mins

For the purpose of this tutorial – let’s focus for now on creating some codeless tests.

So let’s get started. The first thing you need to do is sign up. TestProject is free and it will remain free, so just go to the Sign Up page, enter your name, email, and password and complete the signup process. Once you confirm the registration, sign in to the app and install the TestProject agent. It’s available for Windows, Linux, and Mac OSX:

Download TestProject Agent

Finish all the wizard steps and start the agent. Then, go back in the application, in the Agents tab, and register the agent. That simply means giving it a name so you can easily recognize it. Now your Agents tab should look something like this:

TestProject Agents List

That’s all the preparation needed for TestProject for now.

Preparing the device

When it comes to mobile testing, we can either test on real devices, or we can use mobile emulators and simulators. In this article, I’ll show you how to create mobile tests on an emulated Android device.

For Android devices, we can use Android Studio. Download and install it, then go to AVD Manager to emulate a device:

Android Studio AVD Manager

From here, you can click on Create Virtual Device, and select the device and operating system you want to emulate. Then start it from the list of devices. You’ll have an image of the device open on your machine, and you can use it for anything you would normally do on a mobile device. The cool thing about TestProject is that once your agent is connected, it will automatically recognize the device and all applications installed on it, without any other work required from you.

If you want to use a real Android device, make sure to activate Developer mode, then plug it in a USB on your computer. Then disable the “Verify Apps” options in the phone/tablet settings. The device should now be visible and you can start working on it.

For Apple devices, things are a bit more tricky, but you can follow the instructions provided by the Appium team themselves, or you can check out this really cool article that shows you how to set up an iOS device on Windows.

Installing the apk

Once the device is ready, install the application you want to test. To install an apk on the device simulated with Android Studio, start the device (if it’s not already running) and drag-and-drop the apk. Grab a cup of coffee while it does its magic because that’s all it takes to install it ☕ On a real Android device, download the apk and run the installer.

For this example, we will be using an emulated Android device, and the TestProject demo apk, of course, but you can create Appium automation tests on any app on your real or emulated device.

The first Appium automation tests

Creating the test project

Believe it or not, we are done with the hard part. Let’s start slow, with a recorded mobile test in TestProject. You can create a new project in the app, then click on New Test. When asked which test type, select, of course, Mobile:

Mobile Testing

Enter a name for the test, select the platform (aka operating system) – for this example, we’re using Android, and then, in the Application you’ll be testing field, click on Add a New Application for Testing. This will let you select the device and the target application. Here, you should see either the emulated device, or the connected device, and once you select it, the Application drop-down will populate with all the available apps on that device:

TestProject Android App

On the last step, select Record.

Recording the test

Our demo app contains a simple Sign in page and a form available after the login was successful. So let’s record a successful login and validate that the form is loaded.

You’ll see that the first thing suggested by TestProject is to reset the app. This means that all cached data will be removed from the device. I recommend keeping the step because this way the test will be more reliable. The step will be automatically added to the test:

Reset app

Next, you’ll see the emulated device image inside the TestProject recorder, and the application should start running. Enter a username and a password (the ‘12345’ provided as hint) and click the Login button. Now you’ll see all the recorded steps on the left side of the screen. If you click any step, the details will be expanded. Finding the right locator can be a complex part of creating UI automation tests, but using its built-in AI tools, TestProject will automatically select the best locator for the element you are interacting with:

Mobile Element Locators

You can let TestProject do its thing, or you can click on Edit and modify the element if you feel like that’s needed. If not, let’s move on.

Adding validations to the test

Let’s manually add some validation steps, to check that the login was successful. We’ll check that the Logout button is visible and that the entered username is displayed in the top greeting:

Test validation

This means we don’t want to do any other actions in the application, so we can Pause the recording. Then, from the ➕ button, we can create a new step:

  • Type = “Element action”
  • Element = select the greetings element
  • Action = “Contains Text?”
  • Text = the username entered before. In my case, it’s Andreea:

Validate Text

We’ll use a different method to validate the presence of the Logout button. If you highlight it, you’ll see a hint that pressing double shift will freeze the element. Do that, and this will expand a menu for the element:

Select validation for element

Select Validations -> “Is Clickable?” and confirm. Now we have 2 validations in our test. We won’t add any others, because it’s a good practice to keep test assertions to a minimum.

That’s it! You can click on Play and the test will be run for you from the TestProject app. If all went well, all steps should pass.

Viewing reports

Click on Save and Exit, and go back to your project page. Here you’ll see the test you just recorded, and the actions you can take: Run, Edit, Delete, and More. Click on Run, select the agent and the device, and sit back 😀 You’ll see your steps being automatically executed on the device image. Once it’s done, go to the Reports  page and check out the results and statistics for your test, or you can click on a specific run (so far you should only have one, so click on that) and see the details, including the results for each step:

Appium Automation Tests Results

You can also create a new job from the Project page, and schedule the test to run “On demand” (when you select it and click on Run), “One time” (at a specified time), or “Recurring” (in the specified day(s) of the week and time). Then you will see all the test run results in the Reports tab.

Next tests

Now, you can re-record other scenarios that suit your needs, following the same steps described above, or you can duplicate the existing test and just modify some of the steps and validations. For example, if you want to perform negative testing, you can run the same scenario, but use different data or skip some of the steps (such as entering the username or the password), and change the validations:

Modify Test Step

Test validation

Generating the code

You can take the project to the next step, and generate the code. You can select your programming language of choice, between Java (available for native Appium or the legacy TestProject SDK), C# (available for the legacy TestProject SDK), or Python (available for native Appium SDK).

For this example, I’ll select Java, because it uses native Appium APIs. Once downloaded, unzip the archive and open the project in an IDE. You’ll see in the build.gradle file that the only dependency we are importing is TestProject, because the OpenSDK includes all the Selenium and Appium libraries, so it’s the only library we need to import for both running the Appium tests and for generating the test reports. The test runner is JUnit, which is used to define the setup and teardown methods and to make the assertions in the tests.

Conclusions

That was it! Really, that’s all it takes to create your first Appium automation tests using TestProject – you can create a recorded test that can be modified from the TestProject application, or you can practice your coding skills on the code generated by TestProject.

Either way, setting up the project, including all the device capabilities, locating the elements, adding validations, and generating the test reports should take about 10 minutes ⏱💪

🚀 Kick-off powerful mobile test automation without limitations 🚀
GET YOUR FREE ACCOUNT TODAY

Avatar

About the author

Andreea Draniceanu

Andreea is a QA engineer, experienced in web and desktop applications, and always looking to improve her automation skills and knowledge. Her current focus is automation testing with C#.

Join TestProject Community

Get full access to the world's first cloud-based, open source friendly testing community. Enjoy TestProject's end-to-end test automation Platform, Forum, Blog and Docs - All for FREE.

Join Us Now  

Comments

10 1 comment

Leave a Reply

popup image

Unlock the power of Appium testing

Forget complex setups & maintenance hassles. Focus on creating reliable Android or iOS tests using a FREE Appium-powered platform, with built-in reports, designed to help deliver quality at speed.
Get Started
FacebookLinkedInTwitterEmail