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 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# .
---------------------------------------------------------------------------------------------------
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
·
Download JDK files (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
·
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).
·
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
·
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
·
Run the downloaded .exe file
How to install Eclipse
·
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.
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.
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.
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.
- 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 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 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.
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 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 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.
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.
ReplyDeleteReally 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