How to Use Appium to Test Both Android and iOS Mobile Applications

How to Use Appium to Test Both Android and iOS Mobile Applications

How-To-Use-Appium-to-Test-Both-Android-and-iOS-Mobile-Applications

When we take any smartphone, we can see the 4 types of operating systems over there.

#

Android and iOS are the most popular operating systems on smartphones.

Types of Mobile Applications

  • Mobile Web App Web apps are not real applications; they are actually websites that open on your smartphone with the help of a web browser. Mobile websites have the broadest audience of all the primary types of applications.
  • Native App A native app is developed specifically for one platform. It can be installed through an application store (Such as Google play store & Apple App Store)
  • Hybrid App Hybrid apps are a way to expose content from existing websites in App format. They can be well described as a mixture of Web Apps and Native Apps.

We have multiple tools in the market for testing these types of apps. But the best tool for Android and iOS is Appium.

Appium is an open-source, cross-platform automation testing tool. It is used for automation test cases names of hybrid and web applications. The tool has a significant focus on both android and ios applications.

Read More: What Are the Best Open-Source Web Security Testing Tools?

Advantages of Appium

  • Cross Platform: Android and iOS: we can test Native, Hybrid, and Web Apps.
  • Allows you to communicate with other apps, Ex. WhatsApp (The majority of tools don’t support this)
  • No pre-compilation of your app
  • Support for a built-in app: Alarm, Phone, Calendar, etc
  • Any WebDriver-compatible language is supported: Java, Objective C, Ruby, PHP, C#: we just need language-specific libraries to work on

The Architecture of Appium

  • As Appium is an HTTP server(webserver), it performs pretty much the same as the selenium webdriver server.
  • Appium works as a Client/Server architecture.
  • To JSON wire protocol, the communication will happen with session IDs only.
  • Whenever the Client sends a request, the server will create a session and send back the session ID to the Client so that future communication between the Client and the server will happen with this session ID only.

Q) How will the server identify which session it needs to create?

Ans) The client usually has desired capabilities we need to pass using which the session will be created. DC contains the application name, platform version, package name, and activity name.

  1. Desired Capabilities are sent by the Client to the Server via JSON objects by requesting the automation session we need.
  2. Ref a below dig for a better understanding

#

For Android devices, appium uses the UI Automater framework; bootstrap.jar works as a server and sends the request to the Android Device with the help of UI Automater.

Testing for iOS Devices

Here is also a similar case to Android, but the server sends a request to iOS Device using UI Automation.

Prerequisites for using Appium

To use Appium, we need the following prerequisites:

  1. Node.JS
  2. Java
  3. Android Studio
  4. Eclipse IDE
  5. Appium Server
  6. Appium Client Library
  7. Selenium Jar

Guideline for Appium configuration on Windows

  1. Download Java (Set Java_Home and Java Bin Path in Environment Variables)
  2. Download Android Studio (Please use this URL to download-
    https://developer.android.com/studio)and Install the application in your system
  3. Find out the Android SDK path(C:\Users\user\AppData\Local\Android\Sdk)
  4. Download and Install Node. js-This is a prerequisite to start Appium Server (Please use this URL to download – https://nodejs.org/en/download) and download Windows Installer (.msi) file.
  5. Set Android SDK Path in Environment Variables
    1. Set ANDROID_HOME by providing –
      C:\Users\user\AppData\Local\Android\Sdk this path in system variables.
      #
    2. Set the below path in the PATH of system variables
      (C:\Users\user\AppData\Local\Android\Sdk\platform-tools,
      C:\Users\user\AppData\Local\Android\Sdk\tools,
      C:\Users\user\AppData\Local\Android\Sdk\build-tools,
      C:\Users\user\AppData\Local\Android\Sdk\tools\bin
      C:\Users\user\AppData\Local\Android\Sdk\build-tools\bin)
      #
  6. Set Nord.js Path in Environment Variables Set the below path in the PATH of system variables- (C:\Program Files\nodejs\)
  7. Install and Start Appium Server via Node.js Open the command prompt in Administrator mode and simply type the below npm commands for installation
    1. npm install -g appium@next
  8. Install Appium inspector
    1. Download it from the Appium inspector GitHub page
      https://github.com/appium/appium-inspector/releases
    2. Now install the Appium inspector based on your system specification.
  9. Download Eclipse and create a maven project and add Java Client dependency.
  10. Please provide the desired capabilities (use this Appium official documents for better understanding
    https://appium.io/docs/en/writing-running-appium/caps/
  11. Used Vysor Application to run your script on Real Devices.
  12. If you want to use Emulators then create a device in Android Studio.

Configure a Real Device

  1. Unable to use the Developer option on your mobile (note – Please connect your Mobile device to the system via USB)
    1. Go to the settings menu and click on the about phone icon.
    2. After clicking on the about phone icon, you will be redirected to a page containing all the information related to that phone. Now click on the build version 7 times.
    3. After clicking it 7 times, you will again get a pop-up message stating, “You are now a developer “. This message means that you have enabled the developer options on your phone.
    4. Then verify that developer options are enabled, click on the back button, scroll down for the option “additional settings”, and click on this option.
    5. Then scroll down for the USB debugging option and enable it.
    6. After enabling it, you will get a pop-up message stating, “Allow USB Debugging? “
    7. After clicking on the OK button, you will enable the debugging mode on your phone
    8. Now, in your system, open the command prompt and write the following command: adb devices (this command is used to check the list of devices attached)

Create a Session in Appium Inspector

  1. Start Appium Server on CMD (just put appium command in CMD)
    #
  2. Install the Appium Inspector and open it in your system. Steps to install Appium inspector are given above in step number 8.
  3. Provide the Remote Host- 127.0.0.1 and Remote Port- 4723
  4. Also, provide Desired capabilities and click on Start Session.
    Like this, we can start our test on the Android/iOS device.
    #

Ultimate Guide to Codeless Automated Testing

Download eBook

Ultimate Guide to Codeless Automated Testing

Download eBook