Skip to main content

What is APPIUM

What is Mobile Automation? 

Android & iOS are the most popular mobile OS in these days. Millions of app designed for mobile platforms that need to be tested.

There are broadly 2 kinds of testing that take place on mobile devices:
1. Hardware Testing
2. Software Testing

Here, We will talk about Mobile Software Testing. 

In Mobile Software testing, we refer the term Mobile Application Testing. The applications that work on mobile devices and their functionality are tested. It is called the “Mobile Application Testing” to differentiate it from the earlier method. There are three kinds of Mobile Apps present -


  • Native apps: the Native application is platform dependent and is created for use on a platform like mobile and tablets. i.e Whatsapp, Amazon App, Mobile Music App etc.
  • Mobile web apps: Mobile web apps are server-side apps to access website/s on mobile using different browsers like chrome, Firefox. Like you can see many mobile web apps are available like facebook, Flipkart etc.
  • Hybrid apps: Hybrid apps are combinations of native app and web app. They run on devices or offline and are written using web technologies like HTML5 and CSS.

Mobile Apps should be work on different platforms like different versions of Android and IOS and it should  work on different screen resolution like a mobile tablet. In this way to Test Mobile manually a bit difficult task that's why you need mobile Automation. 

In Mobile Automation, you write the Test Scripts and can run these scripts on desired device or platform version to Test the Application. There are many tools available for mobile Automation like Appium, Selendroid, IOS Driver, Calabash etc. We will discuss and learn about the Appium tool


APPIUM Introduction -


Appium is an open source mobile test automation tool developed and supported by Sauce Labs, Appium supports automation of native and hybrid mobile apps. Appium is also known as a Cross-browser Mobile Automation Tool.

APPIUM uses JSON wire protocol internally to interact with iOS and Android native apps using the Selenium WebDriver. 
JSON wire protocol is used by Selenium WebDriver to communicate with the APPIUM. Let's understand this using a diagram. 


APPIUM Architecture


APPIUM is built on the top of Selenium WebDriver, Webdriver communicates with the APPIUM using JSON wire Protocol, Whatever command fire by Selenium Webdriver, they are communicating with the APPIUM via JSON wire Protocol. 

Appium Architecture


Appium is a HTTP server written in node.js which creates and handles multiple WebDriver 
sessions for different platforms like iOS and Android.

APPIUM works in Android 

As we discussed, Selenium webdriver communicates with the APPIUM using JSON wire protocol and APPIUM uses UIAutomator to communicate with the Android mobile Application. 

UIAutomator is part of Andriod, UIAutomator is an engine which communicates with the Mobile App. UIAutomator is Android’s native UI automation framework which supports running JUnit test cases directly into the device from the command line.It uses java as a programming language but Appium will make it run from any of the WebDriver supported languages.

Why Need APPIUM ?



Appium can make your mobile app regression testing task easy. Especially for large mobile apps where continues apps are updating with new features and functionalities. Another main benefit of using Appium for mobile app automation is : It supports bellow given multiple platforms like - Andriod, IOS, firefoxOS 
APPIUM supports multiple languages as well. You can design the Test Scripts usingJava, Objective-C, JavaScript with Node.js, python, ruby, C# .

---------------------------------------------------------------------------------------------------

Selendroid vs Appium


Now you will see, What is the difference in Selendroid and Appium and Which tool is better for mobile automation Testing.

Selendroid or “Selenium for Android” is a test automation framework which is used ONLY for Android apps. On the other hand, Selendroid needs the APK file of the application to design the Test Scripts. 

Working with Selendroid is not easy as Appium. Selendroid also supports the Multiple Languages. 

Now you will see the differences in Selendroid and Appium.


What is good for Mobile Automation Selendroid or Appium ?


Selendroid and Appium are very similar:
  • Both use Selenium WebDriver.
  • Both could be used for native, hybrid and mobile web apps.
  • Both could run tests on the emulator or real devices.
  • Both are suitable for Cloud-Based Testing.
Selendroid or “Selenium for Android” is a test automation framework which is used ONLY for Android apps. Whereas Appium is an open source automation tool used for Android, iOS and Firefox OS .

Selendroid has multiple Android target API support (10 to 19) and it has no limitation with WebView testing like Appium which uses UIAutomator for API Version>=17.

UI elements locating is easier in Selendroid. In Selendroid, you can find UI element by its id, class, name, XPath, link text, partial link text.

Appium, for example, does not support elements locating by id (in layout *.xml file defined as “android:id=@+id/some_id”). It is because UI Automator does not support it for API<18.


APPIUM & Selendroid Compatibility -


Appium supports all Android API levels but there is one limitation. As it uses uiatomator for tests running on API>=17, for older APIs you need to run tests using Selendroid.


-----------------------------------------------------------------------------------------------------

1.     Appium
2.     Prerequisite to use Appium
Installation:
1.     Andriod SDK files
2.     Eclipse IDE
3.     Java
4.     Apache Maven
5.     TestNG
6.     Selenium Server JAR
7.     Appium
8.     NodeJs

What is Appium?
·        APPIUM is a freely distributed open source mobile application UI testing framework.It supports automation test on physical devices as well as emulator and simulator.
·        It offers cross-platform application testing. i.e, single API used for "Android" and "iOS" platforms respectively.
·        It has no dependency on mobile device "OS". It just translates selenium webdriver commands into UIAutomation(iOS) or UIAutomator(Andriod) commands depending on device type not on "OS".
·        It's client-server architecture that exposes a REST API. It receives connections from a client, listens for commands, executes those commands on a mobile device, and responds with an HTTP response representing the result of the command execution.
·        It supports programming languages like Java, Phython, Ruby, PHP, and Java script.
Prerequisite to use Appium
Before installing Appium following below items should install first on your machine.
1.     JDK (Java Development Kit)
2.     Andriod SDK
3.     TestNG
4.     Eclispe
5.     Selenium Jar
6.     Appium
7.     APK App info from Google Playstore
8.     Nodejs
9.     Git
How to install JDK
·        For Installation follow below steps:
·        Select Start menu > Computer > System Properties > Advanced System Properties 
·         Then open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that points to your JDK folder, for exampleC:\Program Files\Java\jdk1.7.0_21.
·        To verify the successful installation just type "javac" in command prompt.
How to install Android SDK
·        Before installing Android SDK, you need to install Java Development Kit (JDK).
·        Download Android SDK from "http://developer.android.com/sdk/index.html"
·        Again create environment variable Android_Home is set to the JDK installation directory. (Ex: C:\Users\sachin\AppData\Local\Android\sdk)
·        Add tools and platform-tools to your "PATH" variable (Ex: C:\Users\sachin\AppData\Local\Android\sdk\tools;C:\Users\sachin\AppData\Local\Android\sdk\platform-tools;) 
·        Run the downloaded .exe file. 
How to install Apache Maven
·        Download Apache Maven ("http://ant.apache.org/bindownload.cgi")
·        Set M2HOME and M2 environment variables. Set M2HOME to the directory maven installed in, and set M2 to %M2HOME\bin. Add path you used for M2 to your "PATH" variable
·        (ex:M@HOME= C:\Users\amurthy\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3, M2=C:\Users\amurthy\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3\bin, PATH=C:\Users\amurthy\Downloads\apache-ant-1.9.6-bin\apache-ant-1.9.6;C:\Users\amurthy\Downloads\apache-maven-3.3.3-bin\apache-maven-3.3.3\bin)

How to install NodeJs
·        Download Nodejs from nodejs.org
·        Run the downloaded .exe file
How to install Git
·        Download Git ("http://git-scm.com/download/win") 
·        Run the downloaded .exe file
How to install Eclipse
·        Download eclipse ("http://www.eclipse.org/downloads/")
·        For windows user, select the proper one based on the version of your OS (32 bit / 64 bit).
·        Unzip it and run the downloaded .exe file.
How to set latest Android SDK tools
1.     Open the tools directory (ex: C:\Users\sachin\AppData\Local\Android\sdk2) 

2.     Right click on "SDK" folder and select run as "Administrator" option.

---------------------------------------------------------------------------------------------------------------


Start Appium Server Programmatically Using Java

Executing Appium tests for Android and iOS requires Appium server running in background. While you can always start the server manually before running your tests, this may not be a good approach if you are targeting full automation (Eg. while running your tests in CI). Therefore it’s recommended to start Appium server programmatically. This post shows how we can achieve this using Java for Mac and Windows platforms.

Start Appium Server Programmatically

Some background:

Appium server is basically a JavaScript server built using NodeJS. So to start it, we’ll need to supply Appium server JavaScript file to NodeJS executable. We also need to pass additional arguments if required.
Armed with this much information, let’s get into the meat of the matter.

Start Appium server programmatically on Mac:

  • Write below shell script and save it in your system. Here we are supplying NodeJS executable (please note here that NodeJS executable is supplied by Appium itself) followed by Appium.js file and additional arguments such as port and address. You might need to modify these as per your requirements.
  • Write below Java code (preferably in your setup method) to execute the shell script we have written. You may want to add some delay for Appium server to start after this code.
  • The above code will start Appium server on address 127.0.0.1 port 4724 as specified in shell script.

Start Appium server programmatically on Windows:

  • The procedure to start Appium server is more or less same as Mac. You’ll have to supply Node executable, Appium server file and additional arguments. But to execute this command, we will need to use Process class of Java.
  • Write below code in your setup method. You’ll need to change Node and Appium executable as per your system.
  • This will start Appium server on default address and port.

The Basics of Mobile Web Testing on Real Devices Using Selenium

The obvious advantage of starting Appium programmatically is reduced manual intervention. This way testers can run their automated tests during off hours, resulting in higher efficiency. Do you know any other way we can start Appium server programmatically? Do share with us in comments.


Appium and Selenium

Appium is like Selenium – but for mobile apps and games“. You’ve probably read/heard this several times before, but in fact, Appium is much more than that. Appium is also suitable for mobile web testing, when real devices and real browsers are used in testing. Emulators won’t do the trick as e.g. Chrome cannot be even installed on standard Android QEMU-based emulator. Some emulators may work (with Chrome), but why bother – those are still emulators and no single end-user uses emulators to run your app, game or web products. With the same effort (and cost) you can build your test automation with Appium using real stuff.

In its architecture, Appium is an HTTP server written in Node.js that creates and handles multiple WebDriver sessions. Appium starts tests on the device and listens for commands from the main Appium server. It is basically the same as the Selenium server that gets HTTP requests from Selenium client libraries.


Appium 'Behind the scene'


Appium has proven its flexibility and scalability in native mobile app and game testing, as those apps and games built by app and game developers tend to be pretty much identical on both platforms, Android and iOS. The benefit of having these sort of cross-platform framework helps using the identical script either app/game is running on either platform. The very same applies for mobile web. Appium scripts run nicely whether you are testing website on Chrome, Firefox, Safari, WebKit-based browser on Android and iOS (where applicable).



Comments

  1. This blog will help to get more ideas. This is very helpful for Software Testing learners. Thank you for sharing this wonderful site. If someone wants to know about Software QA services this is the right place for you Software QA Companies.

    ReplyDelete
  2. Really Good tips and advises you have just shared. Thank you so much for taking the time to share such a piece of nice information. Looking forward for more views and ideas, Keep up the good work! Visit here for Product Engineering Services | Product Engineering Solutions

    ReplyDelete

Post a Comment

Popular posts from this blog

API Testing With Selenium WebDriver

REST API Testing Framework We will be creating a simple Rest Testing Framework in Java and JUnit that could be used for any testing scenarios. Rest Testing Framework Overview The framework should be able to execute the basic REST operations (GET, POST, PUT, PATCH, DELETE) and perform the validations on the code, message, headers and body of the response. The completed code can be accessed from my  GitHub account   from where you can collect and make modifications based on your requirements. Design We will be having three classes for the framework (in package com.axatrikx.controller ) RestExecutor  : Performs the HTTP operations using Apache Http Client RestResponse  : A javabean class to hold our response values (code, message, headers, body) RestValidator  : Validates the response with the expected values The package  com.axatrikx.test  holds the test scripts. Note: I will be using ‘ json-server ‘ to fake the REST API. Its a real handy tool to r

ExtentReports in Selenium Webdriver

ExtentReports in Selenium Webdriver What is ExtentReport? ExtentReports  is a HTML reporting library for Selenium WebDriver for Java which is extremely easy to use and creates beautiful execution reports. It shows test and step summary, test steps and status in a toggle view for quick analysis Download Download the jar below: Download ExtentReports 1.4 (1623)    Snapshot of Extent report After Executing the Script   Program Steps:  We are going to write three different testcases. Pass Warning Fail TestCase with Pass Result Navigate to http://www.guvi.in Click on Sign-in Enter the credientials Check the URL is correct or not after login   TestCase with Warning Result Verify with the Wrong URL (static String Afterloginfail="http://www.guvi.in/ ")    TestCase with fail Result Click on Menu Select Tech Challenges Verify With wrong URL. Source Code: import  java.io.File; import  java.io.IOException; import   java.sql

How to Compare Two Images in Selenium

How to Compare Two Images in Selenium Some time in testing we have to do image comparision as verification point. So, in this blog I expalin how to compare two images in selenium. I have created one function for compare two images. you can use directly into your framework. first of all you have to import below packages into your code. import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; Now, you can use below function for comparison of two images. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 public boolean mCompareImages ( BufferedImage img1 , BufferedImage img2 ) { boolean bCompareImage = true ; try { if ( img1 . getWidth () == img2 . getWidth () && img1 . getHeight () == img2 . getHeight ()) { for ( int i = 0 ; i < img1 . getWidth (); i ++) { for ( int j = 0 ; j < img1 . getHeight (); j ++) { if ( img1 . get