Introduction to Appium

Appium is an open-source tool for automating native, mobile web, and hybrid applications on iOS devices, Android devices, and Windows desktop platforms. It also supports automation tests on physical devices as well as an emulator or simulator both.

Native apps are those kinds of applications that are written using the iOS, Android, or Windows SDKs.

Mobile web apps can be accessed using a mobile browser (Appium supports Safari on iOS devices and Chrome or the built-in ‘Browser’ app on Android devices).

Hybrid apps use a wrapper around a ‘webview’ — a native control that enables interaction with web content.

 It offers cross-platform applications testing, i.e., one single API works for Android and iOS platform test scripts.

 It has NO dependency on Mobile device OS. APPIUM has a framework or wrapper that translates Selenium Webdriver commands into UIAutomation (iOS) or UIAutomator (Android) commands depending on the device type, not OS type.

Appium supports multiple programming languages such as Ruby, Python, JAVA, JavaScript, C#, and PHP.

How Does Appium Work?

How Does Appium Work? A Flowchart.

  • Appium Server is written in Node.js.
  • It uses a client-server architecture.
  • The test script can be written in multiple programming languages such as Ruby, Python, Java, JavaScript, C#, and PHP.
  • Client machines communicate with the server via the JSON Wire protocol to begin an automation test session by sending a request to the Appium server.
  • The Appium server invokes the iOS or Android drivers by creating a new test automation session.
  • The Appium server ties with the corresponding native testing frameworks to link with the bootstrap.jar/bootstrap.js running on the mobile devices to perform operations on the device.
  • Through Appium, it is feasible for testers/developers to use the same test script to test iOS and Android devices.
  • However, the problematic point here is to differentiate between iOS and Android devices’ test automation requests. Appium overcomes this by providing the desired capabilities. When a request session is created, the key-value pairs such as deviceName, platformName, appPackage, appActivity, etc., have been mentioned. Based on those mentioned key-value pairs, the Appium Server directs the client requests to the corresponding test frameworks.

Appium on Android Devices

  • Client machines communicate with the server via the JSON Wire protocol to begin an automation test session by sending a request to the Appium server.
  • The server checks the desired capabilities. For Android platform testing, the server looks out for the UiAutomator2 — native testing automation framework in Android.
  • UiAutomator2 communicates with the bootstrap.jar running on the device as a TCP server. It works on emulators, simulators, and real devices as well.
  • Bootstrap.jar receives the requests and runs the tests on Android devices. It hands over the test log details to the UiAutomator2 and passes it to the Appium Server. Bootstrap.jar forwards that information to the client.

Appium on iOS Devices

  • Client machines communicate with the server via the JSON Wire protocol to begin an automation test session by sending a request to the Appium server.
  • The server checks the desired capabilities. For iOS platform testing, the server looks out for the XCUITest — native testing automation framework in iOS, which comes with Apple XCode.
  • XCUITest communicates with the bootstrap.js running on the device as a TCP server. It works on emulators, simulators, and real devices as well.
  • Bootstrap.js receives the requests and runs the tests on iOS devices. It hands over the test log details to the XCUITest and passes it to the Appium Server. Bootstrap.js forwards that information to the client.

Getting Started

Installing Appium in Mac

Step 1: Install Node.js and check if it is installed using the following commands:

Step 2: Install Appium and check if it is installed using the following commands:

Step 3: Install Appium client and start Appium:

Also, install an Appium doctor using:

For uninstalling Appium:

  • Installation via Desktop App Download

>> Download and install Appium desktop from http://appium.io/

https://experitest.com/appium-blog/what-is-appium-server/#Appium-Installation

Connect Real Android Device on Mac

Prerequisites

  1. Java installed on the system.
  2. JAVA_HOME is set in environment variables, and to check, use the command java -version.
  3. An Android mobile device.
  4. To connect the mobile device to the computer system, need a cable.

Step 1: Download Android SDK:

Way 1: Download from https://developer.android.com/studio

Way 2:

Step 2: Extract platform-tools folder:

(the platform-tools will be according to the Android version. Refer to: https://en.wikipedia.org/wiki/Android_version_history

Step 3: Add environment variables:

ANDROID_HOME: the path of the android-sdk folder.

PATH: append the path of the platform-tools folder.

Set environment variables Globally on the Mac system use below mentioned command to execute:

If bash_profile does not exist:

Press ‘i’

Add the following:

Setting PATH for ANDROID_HOME:

Adding platform-tools to PATH

Press ‘esc’ and type:

And press enter.

Now ANDROID HOME and PATH are set permanently.

After this run command:

Step 4: Now use a mobile android device for automation:

   Enable developer mode.

   Enable USB debugging.

Step 5: Connect Android device with computer using USB cable:

    If asked, enable USB Debugging.

Step 6: Run command: adb devices

   Check that device ID is displayed.



Source link

Write A Comment