36
Android & iOS automation using Appium Presenter : Abhishek Swain, Mindfire Solutions

Android & iOS Automation Using Appium

Embed Size (px)

DESCRIPTION

This presentation will help anyone interested to have a quick start guide on Appium for automation testing on Android and iOS mobile apps.

Citation preview

Page 1: Android & iOS Automation Using Appium

Android & iOS automation using Appium

Presenter : Abhishek Swain, Mindfire Solutions

Page 2: Android & iOS Automation Using Appium

About Me:

Abhishek Swain, Software QA EngineerMindfire Solutions

Skills : Robotium , Appium , Selenium WebDriver , Maven , Junit , SQL ....

Certifications : ISTQB Foundation Level, V-Skills Selenium Certified

Connect Me :Facebook : http://www.facebook.com/jikun55LinkedIn : http://in.linkedin.com/pub/abhishek-swain/58/8a/829/

Contact Me :Email : [email protected] /[email protected]: mfsi_abhishekswain

Page 3: Android & iOS Automation Using Appium

Agenda

Introduction Features List Current Limitations Understanding Architecture Automating Android Apps

Native/ Hybrid app Mobile Web app

Automating iOS Apps Prerequisites and configurations On Simulators On Real iDevices

Short Demo Questions & Answers

Page 4: Android & iOS Automation Using Appium

Introduction

Appium is an Open source , Cross Platform test automation tool for mobile apps

Hosted with GitHub Maintained by Dan Cuellar, Jonathan Lipps and

a number of other contributorsSupports automation of Native , Hybrid and

Mobile Web appsBased on WebDriver JSON wire protocolBased on Client-Server ArchitectureAppium Server written in Node.js

Page 5: Android & iOS Automation Using Appium

Features

Automation support for iOS Mobile Android Firefox mobile OS

Cross-Platform

Page 6: Android & iOS Automation Using Appium

Features

Automation support for Native App Hybrid App Mobile Web App

Application Types

Page 7: Android & iOS Automation Using Appium

Features

Supports all the WebDriver Client Libraries

Java Ruby Python JavaScript PHP C#

Multiple Client Libraries

Page 8: Android & iOS Automation Using Appium

Features

Common Library for all the mobile platforms e.g. Android , iOS

Selenium WebDriver Interfaces implemented

Added mobile specific functions e.g. driver.pinch(), driver.zoom(), driver.currentActivity(), driver.lock() etc.

Common API for both Native and Web components

Common API

Page 9: Android & iOS Automation Using Appium

Features

Android Real Devices Emulators Native Browser Mobile Chrome

iOS Real iDevices (e.g. iPhone, iPad etc.) Simulators Mobile Safari

Test Modalities

Page 10: Android & iOS Automation Using Appium

Limitations

Android No Support for Toast messages Android Version 4.2+ required

iOS Needs mac OSX 10.7+, lower versions

not supported

Page 11: Android & iOS Automation Using Appium

Architecture

Client Server Architecture Based on WebDriver JSON Wire Protocol Native test libraries of respective platform is

the backbone of the backend

Page 12: Android & iOS Automation Using Appium

Architecture

Android UiAutomator ( Version 4.2 or +)

Default Backend for Android Selendroid ( Version 2.3+)

A separate open source project for Android automation

Instrumentation is the Backend

iOS Apple’s UIAutomation Framework

Which Native Library for Which Platform

Page 13: Android & iOS Automation Using Appium

Automation of Android Apps

Native & Hybrid Apps

Page 14: Android & iOS Automation Using Appium

Requirements : (Java)

JAVA IDE (Eclipse) Java JDK Maven Plugin for Eclipse Selenium WebDriver Dependencies/Appium

Java-Client Dependency (Maven) Android SDK Junit Emulator/ Real Device Appium Server Node.js (If running appium from source)

Page 15: Android & iOS Automation Using Appium

Configurations:

Environment Variables & Path Settings JAVA_HOME ANDROID_HOME MAVEN_HOME

Android Platform Version 4.2+ must be installed

Page 16: Android & iOS Automation Using Appium

Test Script Development :

Create a maven project in Eclipse

Add dependency<dependency>

<groupId>io.appium</groupId> <artifactId>java-client</artifactId> <version>1.1.0</version>

</dependency>

Page 17: Android & iOS Automation Using Appium

Test Script Development :public void setUp() throws Exception { File classpathRoot = new File(System.getProperty("user.dir"));        File appDir = new File(classpathRoot, "../../../apps/");        File app = new File(appDir, "App_Name.apk");        DesiredCapabilities capabilities = new DesiredCapabilities();        capabilities.setCapability("deviceName","Android");        capabilities.setCapability("browserName", "");        capabilities.setCapability("platformVersion", "4.4");        capabilities.setCapability("app", app.getAbsolutePath());        capabilities.setCapability("appPackage", “package_name ");        capabilities.setCapability("appActivity", ".activity_name");        driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);    }public void tearDown() throws Exception {        driver.quit();   }

Page 18: Android & iOS Automation Using Appium

Starting Appium Server

From Source:Install Node.jsDownload Appium or Clone it using GitHubIn cmd navigate to node_modules/appium/binRun 'node appium [server arguments]'

From GUI Interface:Do the configurations as needed from GUIClick launch button to launch appium server

Page 19: Android & iOS Automation Using Appium

Appium Server ArgumentsUsage : node appium [arguments](windows), appium & [arguments] (mac)

--app : To specify the path to the AUT(iOS: .app, android: apk)-U , --udid : Unique device identifier of the connected physical device-a, --address : IP Address to listen on-p, --port : port to listen on--session-override : Enables session override--full-reset : (iOS) Delete the entire simulator folder. (Android) Reset app state by uninstalling app instead of clearing app data. On Android, this will also remove the app after the session is complete.--no-reset : Don't reset app state between sessions -l, --pre-launch : Pre-launch the application before allowing the first session

Complete List : https://github.com/appium/appium/blob/master/docs/en/server-args.md

Page 20: Android & iOS Automation Using Appium

Automation of Android Apps

Web Apps

Page 21: Android & iOS Automation Using Appium

Automating Web Appspublic void setUp() throws Exception {        DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("platformVersion", "4.4"); capabilities.setCapability("platformName","Android");        capabilities.setCapability("deviceName","Android Emulator");        capabilities.setCapability("browserName", "Browser or Chrome");        capabilities.setCapability("platformVersion", "4.4");        capabilities.setCapability("app", app.getAbsolutePath());        driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);    }

Page 22: Android & iOS Automation Using Appium

Automating Web Apps

Download Google Chrome(30+) in PC Navigate to ‘chrome://inspect’ Connect device / Start Emulator Open the browser in the Device/Emulator and

navigate to the URL under test Click on inspect button on Chrome to get the

page source and inspect elements

How to get Locators?

Page 23: Android & iOS Automation Using Appium

Automation of iOS Apps

Page 24: Android & iOS Automation Using Appium

Requirements : (Java) Mac OS X 10.7+ Xcode 4.6.3+ iOS SDKs with Command Line Tools JAVA IDE (Eclipse) Java JDK Maven Plugin for Eclipse Selenium WebDriver Dependencies Junit Simulator/ Real Device Appium Server Node.js (If running appium from source)

Page 25: Android & iOS Automation Using Appium

Configurations: Environment Variables & Path Settings

JAVA_HOME ANDROID_HOME MAVEN_HOME

iOS SDKs with Command Line Tools

Authorize the use of Instuments Sudo grunt authorize (If running from source) An alert prompts to do so if used GUI version of

Appium

Page 26: Android & iOS Automation Using Appium

Collecting the .app build of AUT

Compile and Run the source code of AUT in iOS Simulators

Navigate to Library →Application Support → iPhone Simulator → [version] → Applications → [choose_folder_which_belongs_to_compiled_project] → application_name.app

Page 27: Android & iOS Automation Using Appium

Developing Test Scriptspublic void setUp() throws Exception {        File appDir = new File(System.getProperty("user.dir"), "../../../apps/");        File app = new File(appDir, “App_Name.app");        DesiredCapabilities capabilities = new DesiredCapabilities();        capabilities.setCapability("browserName", "");        capabilities.setCapability("platformVersion", "7.1");        capabilities.setCapability("platformName", "Mac");        capabilities.setCapability("deviceName", "iPhone Simulator");        capabilities.setCapability("app", app.getAbsolutePath());        driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);  }      public void tearDown() throws Exception {        driver.quit();    }

Page 28: Android & iOS Automation Using Appium

Starting Appium ServerFrom Source:From Terminal run the following commands> brew install node # get node.js> npm install -g appium # get appium> npm install wd # get appium client> appium & # start appium

From GUI Interface:> Make required configurations from GUI> Click Launch button to launch appium server

Page 29: Android & iOS Automation Using Appium

Running with Real Devices Specify device UDID with appium server

arguments or with the GUI version Compile source of AUT in debug mode AUT must be compiled with a Developers

Signature and a Developer Provisioning profile(Not Distribution type)

Device must be authorized as a development device with xcode

Specify Bundle ID with appium after installing the ipa or running the AUT project directly to device

Page 30: Android & iOS Automation Using Appium

Appium Server Capabilities

Complete List: https://github.com/appium/appium/blob/master/docs/en/caps.md

Page 31: Android & iOS Automation Using Appium

Locating Elements

By Class (UI component type)E.g UIATextField , UIAStaticText (iOS)android.widget.Button , android.widget.EditText (Android)

By Xpath (An abstract representation of certain element with constraints)

By Id Some of the Mobile JSON Wire Protocol Strategies

Accessibility ID (for iOS the accessibility identifier and for

Android the content-description)

Page 32: Android & iOS Automation Using Appium

Appium Inspector

Inspect Elements and the element hierarchy with a GUI interface

Inspect the associated attributes of an element Easily identify the Xpath for all the elements Find the enable/disable status of an element Record test scripts and export in the desired language Verify mobile commands from Inspector before

implementation

Page 33: Android & iOS Automation Using Appium
Page 34: Android & iOS Automation Using Appium
Page 35: Android & iOS Automation Using Appium

www.mindfiresolutions.com

https://www.facebook.com/MindfireSolutions

http://www.linkedin.com/company/mindfire-solutions

http://twitter.com/mindfires

Page 36: Android & iOS Automation Using Appium

References

appium.io github.com/appium/appium