- by Rahul R
If you have been working on selenium from then you may have come across AndroidWebDriver and Selendroid. Though both of them are limited to only Android devices. AndroidWebDriver has been deprecated in favour of Selendoid. But what if there were a library that can be used for both Android and iOS devices or emulators. And this is what Appium does. Appium is an open-source library that can be used to automate native, mobile web, and hybrid applications for iOS and Android platforms. Native apps are created using iOS or Android SDKs. Mobile web apps are web apps accessed on a mobile browser. Hybrid apps are hosted inside a native application that utilizes a mobile platform’s WebView.
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. 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 behaviours over a session.
Let’s get an example to understand 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.
Appium supports Safari on iOS phone and Chrome or the built-in ‘Browser’ on Android phone. Tests can also be run on Android and iOS emulator, but well emulators are emulators cannot replace the real device. So if you have a real device at your disposal then avoid emulators. It offers cross-platform application testing i.e. single API works for both Android and iOS platform test scripts. It has NO dependency on Mobile device OS. Because, Appium has a framework or wrapper that translate Selenium Webdriver commands into UIAutomation (iOS) or UIAutomator (Android) commands depending on the device type, not any OS type. Appium supports all languages that have Selenium client libraries like- Java, Objective-C, JavaScript with node.js, PHP, Ruby, Python, C# etc.
Tools required to go for mobile automation :
- Android SDK/Studio – Download
- Java Development Kit – Download
- Eclipse (or other IDE suits you) – Download
- Selenium Standalone Jar – Download
- TestNG – Download
- Appium – Download
- Node.js (Optional – Whenever Appium server is installed, it by default comes with “Node.exe” & NPM. It’s included in the Current version of Appium.)