An Introduction to Appium: The Best Open Source Mobile App Automation Tool
Thousands of apps are released every
day, be it native, hybrid or web apps, and they all fall into different
categories ranging from highly secure banking apps to fun inducing video games.
At the rate at which apps are released, it is important to check them for
functionality, consistency and usability. There are powerful testing tools that
would help you with the performance of hybrid, mobile web and native mobile
applications, and some of them are cross platform.
Appium, though essentially an HTTP server
can manage Web Driver sessions, as it is really an open source project for
cross-platform test automation. And since it is supported and developed by
Sauce Labs, it is easily picked up by the Web Driver community for mobile apps.
Appium can support any tests on any
framework and in any language. Testing is simple because you don’t have to
modify the codes for testing. The best thing about Appium is that it supports
all kinds of apps, so you can run the tests on either iOS or Android on real
devices.
What is Mobile Automation Testing?
Mobile application testing can
be automated or manual. By checking the application and the outcome,
programmers can decide on any changes to be made if required. By constantly
checking the application outcome, testing can be done successfully, thereby
expediting the process of validating the software.
The need for mobile automation testing
stemmed from the explosive growth of smartphone applications since 2007. The
total number of applications in App Store and Google Play jointly exceeds one
million+. As all these applications are competing for user attention,
maintaining the quality of apps has become quintessential.
Nevertheless, there are some
challenges that mobile test automation suites have to go through. Some of them
are:
·
Limitations
of mobile memory size
·
Multiple
network types like Wifi, Wimax, GSM, GPRS
·
Multiple
platforms and browsers
·
Limitation
in processing speed
·
Different
device communication protocols
If you are looking for Appium Installation guide Refer our previous article
Introduction to Appium- The Best Tool for Mobile App Automation
Appium is cross-platform and allows
you to write against multiple platforms because it allows for code reuse
between Windows, Android and iOS test suites. Being an open source tool, it is
the perfect choice for automating native, mobile web and hybrid applications on
their respective platforms.
This is the Appium philosophy. All the
mobile automation needs are based on the philosophy in these four tenets:
1. You shouldn’t have to recompile
your app or modify it in any way in order to automate it.
2. You shouldn’t be locked into a
specific language or framework to write and run your tests.
3. A mobile automation framework
shouldn’t reinvent the wheel when it comes to automation APIs.
4. A mobile automation framework
should be open source, in spirit and practice as well as in name!
By using Selenium Web Driver, you can
write tests through Appium via JSON for iOS automated testing. It acts as a
wrapper that translates Selenium commands into iOS and Android commands, making
the framework Selenium Web Driver compatible. Selenium supports the following
languages — Java, Python C#, Ruby, JavaScript,
PHP. Appium also has Android Driver and iOS Driver classes for mobile
automation on Android and iOS platforms as well.
Why Choose Appium?
1. You don’t have to modify codes or
do a recompilation of your app because of the standard API that it uses in all
the platforms. Appium makes it easy to write your tests against iOS and Android
platforms with same API, but you will still need separate iOS and Android
scripts, as the UI elements are separate on both the platforms.
2. Programmers can use any Web Driver
compatible language to write the tests for the apps. Examples would be Perl
with Selenium Web Driver API, Objective-C, Java, PHP, C#, Python, Clojure, Ruby,
JavaScript with Node.js and language-specific client libraries.
3. Programmers can use the testing
framework of their choice. This is a far cry when compared to the Web Driver protocol that you had probably used previously. For example, you can write
tests only through JavaScript through the UI Automation of library for Apple.
Similarly, for the UIAutomator of Google, you can write only Java based tests.
This changed when Appium came on the scene.
The possibility of true cross-platform
native mobile automation through Appium became a blessing, a reality.
How does Appium do all this?
Appium is highly regarded in the
mobile testing world because it makes your mobile app regression testing easy.
This is a great boon for large applications where you have continuous feature
updates and new functionalities. And it allows you to use any testing framework
because of its bevy of multiple platforms and languages.
Now let’s get a tad deeper into the
basics of Appium. Appium is an HTTP web server written in Node.js platform, and
evolved from Selenium. When Appium is downloaded and installed, a server will
be set up on your machine, exposing a REST API. It drives the iOS and Android
session using WebDriver JSON. You must, however, pre-install Node.js on the
system before initializing Appium Server.
Selenium WebDriver and JSON Wire
Protocol let you have internal interaction with iOS and Android applications.
Appium is client-server architecture.
This means that it receives connections from a client, listens for commands,
performs those commands on the mobile device, and responds with an HTTP
response representing the result of command execution. Since Appium is client/server
architecture, you have a lot of possibilities, because you can easily use any
of the Appium client libraries, even though you can write tests codes in a
language with http client API.
There are other automation tools in
the market like MonkeyTalk, Calabash, Frank, KIF, etc. that help you automate
mobile native apps, but you need extra agents compiled in your application to
make them interact with the mobile app. This is a disadvantage because it
becomes slightly different from the apps you are submitting in the App Store,
and you would have to remove those automation agent libraries and only then
submit the app.
It is also worth noting here that
Appium is at heart a web server that exposes a REST API.
- It receives connection in the form client
- Follows the commands you issue
- Execute the commands on the device
- Responds back with an HTTP response that represents the result of command execution.
The Concepts of Appium
Client/Server Architecture
Since you have client/server
architecture, there are a lot of possibilities with Appium. You can use one of
the Appium client libraries or you can write the test code in any language that
has an HTTP client API. You can put the server on any machine, irrespective of
the machine your test is running on. Write the test code and rely on Sauce Labs,
a cloud library, to receive and interpret the commands.
Desired Capabilities
A set of keys and values are sent to
the Appium server to specify the type of automation session to be initiated. It
is also possible to modify the server behavior during automation.
Session
All the automation tasks are performed
under the context of a session. When the client initiates a session with a
server, a Post/session request is sent to the server with a JSON object called
the desired capabilities object. This way, the session starts with an
automation session and shows a session ID through which further commands are
sent.
Appium Server
Appium is written in Node.js. There are
two ways to do this — it can be built and installed from
the source, or installed directly from NPM:
$ npm install -g appium
$ appium
Appium Clients
Client libraries like Java, Ruby,
Python, and PHP, JavaScript, and C # support Appium extensions to the WebDriver
protocol. Programmers can use these client libraries instead of your regular
WebDriver client while running Appium.
Appium Desktop
You can download the GUI wrappers
around Appium server. They have all that you need to run the Appium server, so
don’t worry about the Node. An additional benefit is the possibility to check
the hierarchy of your app when writing and running the tests. This is done with
the help of Appium provided Inspectors.
Advantages of Using Appium
- No Code Change Required: You can use the same source code while running the tests, so you don’t require access to any source code or library. Test your native, hybrid and web apps with the same codes (there is no need to modify them) you are going to ship.
- No Particular Language: Another advantage with Appium is that it lets you write tests with whichever development tools you are comfortable with, using any Web Driver-compatible language such as Java, Objective-C, JavaScript (Node), PHP, Python, Ruby, C#, Clojure, or Perl with the Selenium Web Driver API and language-specific client libraries.
- Multi-Platform Support: Appium uses the JSON wire protocol to interact with Android and iOS along with Selenium Web Driver. To automate iOS apps, Appium makes use of the libraries provided by Apple with the help of an application called Instruments. In Android too, the process is almost similar where Appium proxies the automation command to the UIAutomator test case running on the device. Android has a native UI automation framework called UIAutomator which supports running J Unit test cases from the command line directly into the device.
- When you invest in the Web Driver protocol, it means you are leaving the proprietary stack and have explored the benefits of using a single, free and open protocol for testing. This has already become the web standard for testing.
- Open Source: Being an open source testing framework is one of the biggest benefits of Appium as it supports Simulators or Emulators, and of course, native, hybrid and web application testing of IOS and android. The highly active community of developers makes it easy for new developers to clear their doubts.
Appium works almost like the Selenium
server which listens and understands http requests from Selenium client
libraries, and then performs the tasks in different ways depending on which
platform it is testing on. Similarly, Appium starts a test case on a device
spawning a server, performing tasks after listening to the proxied commands
from the main Appium server.
Other major benefits of Appium with an
Automation framework are:
1. Better quality of product — Appium testing helps you release high quality, functional apps when
compared to other frameworks because the testing is so accurate and realistic.
2. Faster release cycles — As
everything is done automatically, there is no intervention or halt while the
testing is going on, and you can enjoy faster release cycles.
3. More features — As the
overall testing time is reduced, Appium allows you to implement more features
per release. You can test more features and updates to your app, because the
overall testing time is reduced. The number of features added in your app will
not increase the testing time.
4. “Closest to live” testing
scenarios — since the app is tested as it is, you
don’t have to add extra codes in it. This gives you a real life scenario of how
your app will perform when it gets into user’s hands.
Conclusion
Since all the complexities remain
under the hood of the Appium server, irrespective of the platform being used,
the programmer will be able to automate the testing process seamlessly. As Appium opens the
door to cross-platform mobile testing, programmers can conduct the tests on
multiple platforms. And programmers do not have to add extra agents to make it
automation friendly. They can test the app in the same way they are planning to
submit it to the app stores.
In short, the entire work release flow
process becomes easy because Appium makes the release cycle short and
facilitates bug free versions of your app, all with a very low TMM (Time to
Market).
Wondering which tool to use for
automated testing of your mobile app? We can guide you…
Comments
Post a Comment