Mobile test automation with Appium
Test automation isn’t a new topic discussed by the software development and testing community. However, mobile test automation is a relatively fresh trend. And the demand for the service is continuously growing. Mainly, it is attributed to the fact that mobile apps get more functionality and adopt the role of the desktop PC.
However, the attempt to get the market share first doesn’t always allow for timely testing. Manual testers don’t manage to run all regression tests as fast as needed. And this is where automation comes to help.
Benefits of mobile test automation
The main benefits of automated testing for mobile apps coincide with those typical of web apps testing:
- Automated tests run faster than the manual ones
- No human errors
- Opportunity to perform simultaneous testing across various devices
- Coverage of multiple localizations
The advantages are significant, yet the drawbacks are also worth consideration:
- Once the operating system is updated, automated tests will stop functioning until the framework is also updated.
- It takes more time to develop a test automation script for mobile apps. Compare: one script for web apps takes 8 hours, while for mobile an engineer will have to spend about 20 hours.
- Many mobile test automation tools lack stability.
- UI components differ from one mobile platform to another. Due to the overall variety, it’s very difficult to come up with a single tool that will go well with all kinds of UI. It’s either technically impossible or the development will cost too much and bring the benefit from automation to nothing.
- Special requirement to iOS: all .ipa files should be signed with a development identity.
Choosing the right approach and tools for automation
When it comes to development test automation scripts for web apps, there are very few questions arise. Selenium WebDriver is highly-adopted open-source framework appreciated by all professional QA teams.
However, with mobile apps the situation is a bit different and the choice isn’t that obvious.
The main question, by the way, isn’t related to tools selection, but to the approach. The selected approach will predefine the tools and the automation process.
Generally, there are two techniques to automate mobile apps testing:
- Record and Play
- Screen Object-Mapping
Record and Play used to be very popular in the early days. The software records and logs all actions performed by the manual tester, including every mouse movement, clicks, and screenshots, and develops the code that will test the app.
Pros: fast implementation, no knowledge in programming is required
Cons: the test scripts can not be tweaked and as soon as the app is changed, the script should be re-recorded
Another technique is UI elements mapping. The approach is commonly known as Screen Object-Mapping.
All UI elements are treated as an object class, and the identifier for this class is stored in the object map.
The approach works as follows. The test script contains the logical name for the object. When the automation engine of the test framework reads the test data (login and password), it picks up the logical name of the object, select the class identifier from the object map, calls the wrapper function for the object class “Login page,” and performs the required action.
Pros:
The code is reusable
The test script is reliable and isn’t sensitive to app changes
Easy-to-understand logic
Cons:
Programming knowledge is required
Time-consuming development of scripts
We recommend to implement the second approach to provide thorough testing of the software. If you in-house team lacks the knowledge, consider hiring the third-party QA vendors to perform automation.
When you’ve selected the approach, it’s time to consider the available tools and choose the right one.
There is a great number of test automation frameworks. In the picture below you can see the most popular of them. Pay attention that some of them are language-specific (Xamarin for C# apps only). Some of them may appear to be too costly (Ranorex, for example).
That’s why it’s very important to weigh all pros and cons of the process and of the tool before making a sensible decision.
The a1qa team recommends paying attention to the Appium framework.
Appium — best choice for mobile automation for iOS and Android
Appium is a free open-source test automation tool for native, hybrid and mobile web apps, tested on simulators (iOS, FirefoxOS), emulators (Android), and real devices.
One of the key advantages of Appium is the support for different scripting languages: Java, Ruby, Python, C#, PHP.
Before getting down to work with Appium, it’s necessary to set up the environment composed of the following elements:
Let us elaborate. First of all, we install Appium Server that will map the initially generated code with various devices or emulators.
Then it’s turn to install Xcode and Android Studio with Android SDK. This will enable us to run tests on emulators, if you want to.
After defining the programming language that will be used for developing test scripts, it’s vital to install the pack of libraries. For instance, if your choice is Java language, then you’ll need Java Development Kit.
Once the software is installed, take care of the app itself. You’ll need .apk file for Android products or .ipa files for iOS. These files function as containers and make sure that the selected app can be uploaded to the necessary device.
Real devices vs emulators
Real devices or emulators? This is probably the most troublesome question for the engineers who perform testing of mobile apps. We won’t talk much about it now, as we’ve previously addressed the issue here.
The main point is that while using emulators is less expensive, it will put additional pressure on the machines thus slowing down testing.
Also, the results delivered by testing on emulators are not always valid. It’s not a rare case that test results on emulators are positive, while the launch on a real device is blocked and the test fails.
Considering this fact, the a1qa automation engineers run tests on real devices only.
Summing up
If you’ve decided that mobile apps test automation is what you need on your project, make sure that the chosen approach and framework will benefit to your team and project requirements. By identifying this, you’ll build solid foundation for achieving the main goal – deliver a high-quality product within the set time limits.