Appium

38
Automation for Apps Anuradha Malalasena

Transcript of Appium

Page 1: Appium

Automation for Apps

Anuradha Malalasena

Page 2: Appium

Agenda What is Appium Getting Started with Appium

Setting up test environment Node Installation and Appium GUI

Demo Windows Automation Android Automation

Native App Hybrid App Mobile Web

References

Page 3: Appium

Let’s meet Appium

Page 4: Appium

What is Appium Appium is an open-source tool for automating native, mobile web, and

hybrid applications. "Appium" is selenium-like testing framework that implements the

"WebDriver" protocol. Supports iOS, Android and Windows Platforms

Page 5: Appium

Appium Philosophy1. You shouldn’t have to recompile your app or modify it in any way in order to

automate it.

2. You shouldn’t be locked into a specific language or framework to write and run your tests.

WebDriver specifies a client-server protocol (client can written in any language) Free to use whatever test runner and test framework

3. A mobile automation framework shouldn’t reinvent the wheel when it comes to automation APIs.• WebDriver has become the standard for automating web browsers

4. A mobile automation framework should be open source, in spirit and practice as well as in name!

Page 6: Appium

Appium Architecture - Client/Server Appium is a webserver 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.

Appium is a server written in Node.js. It can be built and installed from source or directly from NPM.

There are client libraries (in Java, Ruby, Python, PHP, JavaScript, and C#) which support Appium’s extensions to the WebDriver protocol.

Page 7: Appium

Appium Architecture - Session Automation is always performed in the context of a session. Clients initiate a session with a server in ways specific to each library, BUT they all end up sending a 'POST /session' request to the server, with a

JSON object called the ‘Desired Capabilities’. After that, Server will start up the automation session and respond with a

session ID which can be used in sending further commands.

Page 8: Appium

Appium Architecture - Desired Capabilities

Desired capabilities are sets of keys and values sent to the Appium server to tell the server what kind of automation session we’re interested in starting up.

Page 9: Appium

Appium Architecture - iOS

bootstrap.jsApple Instruments

Page 10: Appium

Appium Architecture - Android

bootstrap.jar

UIAutomator

Android 2.3+

Android 4.2+

Page 11: Appium

Appium Architecture - Windows

WinAppDriver

Windows 10 PC

Page 12: Appium

Appium Architecture – JSONWP JSON wire protocol (JSONWP) is a transport mechanism created by

WebDriver developers. predefined, standardized endpoints exposed via a RESTful API

Appium implements the Mobile JSONWP, the extension to the Selenium JSONWP /session/:sessionId/element /session/:sessionId/elements /session/:sessionId/element/:id/click

Page 13: Appium

Desired CapabilitiesCapability Details

automationName Android SDK version less than 17, then you need to define the value as Selendroid; otherwise, the capability takes the default value as Appium.

platformName iOS, Android, FirefoxOS, WindowsplatformVersion OS version of the device deviceName Type of device ( Android Emulator, Moto x, Nexus 5)App Absolute local path or remote HTTP URL of the .ipa,.apk, or .zip file.browserName If you want to automate mobile web applications, then you have to

use this capability to define the browser.

http://appium.io/slate/en/master/?csharp#appium-server-capabilities

Page 14: Appium

Desired Capabilities - AndroidCapability Details

appPackage Java package of the Android app that you want to run

appActivity Android activity that you want to launch

Avd Name of avd that you want to launch

http://appium.io/slate/en/master/?csharp#android-only

Page 15: Appium

How to get .apk info Already Installed

Plug the device Adb shell dumpsys window windows | grep –E 'mCurrentFocus|mFocusedApp‘

Have .apk file Use Appium GUI

Page 16: Appium

Desired Capabilities - iOS

http://appium.io/slate/en/master/?csharp#ios-only

Page 17: Appium

Desired Capabilities - Windows

http://appium.io/slate/en/master/?csharp#winappdriver-only

Page 18: Appium

Get Ready!

Page 19: Appium

System Requirements – Android on Windows

JDK (version 7 or later) Android SDK API (version 17 or later) Android Virtual Device (AVD) or real device

Page 20: Appium

Appium installation – Android on Windows

Install JDK Setup JAVA_HOME and Path variables

Install Android SDK Setup ANDRIOD_HOME variables

Appium on Node.js or Appium.exe Android Virtual Device (AVD) or Real Device Enable USB Debugging

Page 21: Appium

System Requirements – iOS Mac OS X 10.7 or later Xcode Java version 7 or later Homebrew Node and npm

Page 22: Appium

System Requirements – Windows Windows 10 Anniversary Edition or higher Enable Developer Mode Windows SDK WinAppDriver (Appium 1.6 or higher)

Page 23: Appium

Play Time!

Page 24: Appium

Starting Appium Server Appium GUI

Appium 1.4 (only Android and iOS) Appium with Node.js

Appium 1.6 (including Windows support) WinAppDriver

Page 25: Appium

Appium GUI This is a GUI wrappers around the Appium

server. These come bundled with everything required

to run the Appium server (including Node.Js). It has inbuilt Inspector, which enables to find

out elements.

Page 26: Appium

Appium with Node.js $ npm install -g appium $ appium

Page 27: Appium

WinAppDriver.exe

Page 28: Appium

Inspecting Elements Appium Inspector (Appium GUI)

Pre-launch the App Android ‘uiautomatorviewer.bat’ (Android SDK) Windows ‘inspect.exe’ (Windows SDK) Chrome Inspector – Remote Devices (WebView App / Mobile Web)

setWebContentsDebuggingEnabled flag set to true

Page 29: Appium

Write the Script Any WebDriver compatible language

Ruby Python Java JavaScript PHP C# RobotFramework

Any IDE Any Testing Framework

Page 30: Appium

Write the Script - Demo Language - C# IDE - Visual Studio 2015 Testing Framework - Visual Studio Unit Testing Framework

Page 31: Appium

Demo – Windows

Page 32: Appium

Demo – Mobile Web

Page 33: Appium

Demo – Android Native

Page 34: Appium

Demo – Android Hybrid

Page 35: Appium

References http://appium.io/slate/en/master/?csharp#introduction-to-appium

Page 36: Appium

References

Page 37: Appium

Questions ?

Page 38: Appium

Thank You !