The main issue with mobile test automation is having to maintain different test suites for different Android and iOS devices. Appium helps to minimize the number of tests since it can run on both Android and iOS.
So you only need to run one test that works again for all platforms.
The main core contributor to Appium Jonathon Lipps said that the mission for this project is automation for apps everywhere on all platforms.
To learn how in this post, you'll discover what is Appium, how it works and some tips to make your mobile test more reliable.
So in this guide, you will learn about:
- What is Appium
- How Appium Works
- Appium Architecture
- Appium for iOS
- Appium for Android
- JSON Wire Protocol
- Appium 2.0
- Advantages of Appium
- Advice from the Core Contributors
What is Appium?
Appium is a free, open-source, cross-platform mobile UI automation framework. It allows you to write UI tests for your mobile apps, for Android iOS, and some other OSs.
It also lets you write it using the Selenium JSON writer that you know and love from web automation.
Best of all Because it doesn't have any dependency on the mobile device OS you can run the same test across Android and iOS devices.
How Appium Works
A great way to think about Appium is that it's simply a server that runs, and listens to your HTTP requests just like any other server.
All the language bindings (like C#, Python, Ruby, etc.) do is send web requests to a server, and because Appium uses the same protocol as Selenium it is able to translate.
Dan said this is possible because they were able to re-purpose and lots of existing Selenium code, which in turn allows Appium to use all the Selenium language bindings.
And since Appium talks the same protocol over HTTP, the Selenium bindings can just talk to Appium, and Appium can talk back.
That's how it works with all of them — with very little effort.
Appium Architecture
Appium is a Javascript app that runs in NodeJs; it sits there and just listens for whatever requests it might receive. And then, we already have the Selenium clients who can send in those kinds of web requests, and Appium simply hooks them in.
So at its heart, it's a web server that exposes a Rest API and uses JSON protocol to communicate between your script, the Appium server, and real or virtual devices.
Appium iOS
Appium works on iOS by interacting with the UIAutomation Library. Appium 1.5 also includes an iOS implementation, which does not use UI automation Javascript but rather the new Swift XC UI tests library. So you are future proof going forward and Appium, Appium will continue to work with versions of Xcode that continue to support UI automation Javascript.
Find out more about Version 2.0 and what it means for your android automated test and ios automation.
Appium Android
The Appium android support works by using the UIAutomator framework for newer platforms and Selendroid for older Android platforms.
What is the Json Wire Protocol?
The JSON wire protocol is a transport mechanism that was created by the Selenium webdriver folks. You can interact with it using a REST API. Appium implements the mobile JSON wire protocol, which allows it to control different mobile devices and behaviors over a session.
Jason has a cool analogy to explain the JSON wire protocol. You can think of JSON as the telephone power lines that transmit your information. They're mainly categorized by the verbiage they use like do, get, or post methods, but Appium manages its runs through sessions, and we think of JSON as the infrastructure your code travels down in those sessions.
You can think of a session as a run. Each time the server's started and a new test case is run, a new session begins. After your test works through your test and flow for your instance, it tears down Appium, your session is finished.
What's new in Appium 2.0?
Basically Appium is going on a diet.
Currently, when you download Appium it comes with everything that is supported in one piece of software. So many folks have drivers for things that they will never use which creates bloat and slows things down.
One of the big ideas behind Appium 2.0 is that platform support should be encapsulated everything into different drivers. This mixed and matched installed piecemeal approach should help to keep your CI builds slim and fast and light.
This will also create an opportunity for a more robust Appium driver plugin kind of ecosystem.
Why Choose Appium for Your Mobile App Testing?
- First, since Appium is a subset of the Selenium WebDriver JSON wire Protocol, if you are already familiar with Selenium, Appium should be easy enough for you to pick up. For example, you find elements by using a subset of WebDriver's element-finding strategies.
- Second, Appium is becoming an industry standard for mobile testing, much as Selenium WebDriver become the industry standard for browser-based automation a few years ago.
Dan points to Appium really gaining momentum a year or so ago when Appium passed over Robotium and then Calabash to become the tool that most automation engineers were gravitating towards for their mobile testing efforts.
Also, many large companies like Amazon, Zameron, Perfecto Mobile, and others decided to put Appium into their clouds, which was a huge win for Appium adoption.
When you see big companies like Microsoft actually working on getting Appium support built into their mobile operating system I definitely think you’ll agree that it appears that we've hit that point where Appium really is become the defacto standard for mobile test automation.
James agrees and is seeing more and more companies use Appium to automate their tests. Unlike test frameworks such as Calabash, there's no real need to recompile or add any third party framework to your app just to test it. That means you're testing the same app you're shipping, and you're able to execute tests on a real production build.
Some folks say that Appium is slow compared to native testing tools but this is many times caused to poor coding. here are the top mistakes, automation engineers make when creating Appium web driver tests.
What You Need to Know to Get Started with Appium
It's important to understand Selenium driver protocol, and really nail down which programming language you want to use. Of course, the best course of action is to just download Appium from github and get started.
Expert Actionable Appium Advice
At the end of every TestTalks episode, I ask for one piece of actionable advice for my listeners.
Dan Cuellar recommended reading the release notes because they’re always tweaking stuff to make it better. A lot of the time, that knowledge doesn't get out any other way. They do release almost every two weeks. So read the release notes — there's good stuff in there. It will also prevent the hundreds of bogus bugs logged in the Appium repository.
James Koch also mentioned that when he was starting out, there wasn’t any solid, centralized information to follow along with to get started with Appium. Since then, however, more and more people have written about it, and a good number of processes have been developed. He recommends that you take notes on what everyone else is doing, gains an understanding of those processes, and organize that knowledge to adapt it to your own structure. As James would say, if you're brand new to Appium, hit the ground running and just start learning it.
Jonathan Lipps‘s the main man behind all the latest Appium innovations actionable advice that he recommends is to check out the new docs section because they've been completely redesigned and reorganized and updated. So things are so much better than they were. You'll find essentially an API reference for Appium which is something that they've never had. So every command that Appium supports it has which client libraries it's available in which drivers it's supported by code examples and all the rest and we've put a lot of work into this. So if you've gone to the Appium site before and been disappointed with the docs like I've been for a number of years go check it out again today — Appium.io.
How to run appium on real iOS devices