appium solution

62
1 Confidential and propriety Galil Software, Ltd. 2012 6/13/22 Automation for Mobile Apps - Appium solution thor: el Abd Aljawad – QA Automation Technical Leader

Upload: nael-abd-eljawad

Post on 08-Jan-2017

523 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Appium solution

1Confidential and propriety Galil Software, Ltd. 2012

May 2, 2023

Automation for Mobile Apps - Appium solution

Author:Nael Abd Aljawad – QA Automation Technical Leader

Page 2: Appium solution

2Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Mobile Automation Tools Comparison 

Page 3: Appium solution

3Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Appium drives iOS and Android apps using the WebDriver protocol. Appium is an open source test automation framework for use with

native, hybrid and mobile web apps.

Appium Solution

Page 4: Appium solution

4

What is it?

Native App – A native app is an app which is built for a specific platform using specific technologies like Xcode for iOS and Java for Android.

Hybrid App – A hybrid app is an app which uses native as well as web technologies to bring best of both worlds.

Html5 App – Html5 app is not installed on a phone. It runs on a browser and built using web technologies such that it is fully optimized for screen it runs on.

Page 5: Appium solution

5

Page 6: Appium solution

6

Features Comparison

Feature Native Hybrid HTML5Performance Fast Controlled SlowMulti-touch/pinch Yes Yes NoDevice Access All Almost all Very fewSecure storage Yes Yes Shared/NoConnectivity Online/Offline Online/Offline Mostly OnlineRollout Slow/painful Slow/painful FastSecurity High Low LowBest for Games/low content Medium dynamic content High dynamic content

Tools Xcode, Eclipse Phonegap, Worklight Any web basedDistribution Downloaded to device

from AppStoreHosted on a Web server and accessed on a Web Browser

Downloaded to device from AppStore

Integration Supports integration with device features such as camera and address book

Doesn’t support integration with device components

Supports integration with device features such as camera and address book

Notifications Yes No Yes

Page 7: Appium solution

7

Market overview

Facebook moved away from HTML5 apps Twitter uses hybrid app approach A lot of ecommerce sites have HTML5 based mobile websites LinkedIn also recently moved to native app

Page 8: Appium solution

8

HTML5 vs. Hybrid vs. Native

Page 9: Appium solution

9

Appium Philosophy

Appium was designed to meet mobile automation needs according to a philosophy outlined by the following four tenets:1. You shouldn't have to recompile your app or modify it in any way in

order to automate it. you're testing the same app you're shipping2. You shouldn't be locked into a specific language or framework to write

and run your tests

3. A mobile automation framework shouldn't reinvent the wheel when it comes to automation APIs. extended the JSON protocol with extra API methods useful for mobile automation

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

Page 10: Appium solution

10

What is Appium ?

Appium is an HTTP server that creates and handles WebDriver sessions

Appium starts a “test case” on the device that spawns a server and listens for proxied commands

On Android, Appium proxies commands to a UiAutomator test case running on the device

On iOS Appium proxies commands to a UIAutomation script running in Instruments

Page 11: Appium solution

11Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Client/Server Architecture

Receives connections from a client Listens for commands Executes the commands on a mobile device Responds with an HTTP response representing the result of the

command execution

Page 12: Appium solution

12

Selenium WebDriver

Script (C#,Java,Perl,Python,PHP)

Server written in node.js

 

IDEJSON WIRE Protocol via http

UIAutomator

request via USB

UIAutomation request via USB

Page 13: Appium solution

13Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Appium Architecture

Page 14: Appium solution

14Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Session

Session Object

Clients initiate a session with a server in ways specific to each library All libraries end up sending a POST /session request to the server,

with a JSON object called the 'desired capabilities' object the server will start up the automation session and respond with a

session ID which is used for sending further commands

Page 15: Appium solution

15Confidential and propriety Galil Software, Ltd. 2012

25.12.11

JSON

Desired capabilities tell the Appium server what kind of automation session we're interested in starting up

There are various capabilities which can modify the behavior of the server during automation (e.g. tell Appium that we want an iOS session, rather than an Android one)

Desired Capabilities

Page 16: Appium solution

16Confidential and propriety Galil Software, Ltd. 2012

25.12.11

AppiumServer

Appium Server

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

NPM

Page 17: Appium solution

17Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Appium Clients

There are client libraries (in Java, Ruby, Python, PHP, JavaScript, and C#) which support Appium's extensions to the WebDriver protocol. When using Appium, you want to use these client libraries instead of your regular WebDriver client.

Page 18: Appium solution

18Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Appium on real iOS devices Appium has support for real device testing.

To get started on a real device, you will need the following:

An Apple Developer ID and a valid Developer Account with a configured distribution certificate and provisioning profile.

An iPad or iPhone. Make sure this has been set up for development in Xcode. See this article for more information.

A signed .ipa file of your app, or the source code to build one. A Mac with Xcode and the Xcode Command Line Developer Tools.

Page 19: Appium solution

19

Language Clients

Github Repo and Installation Instructions Language/Frameworkhttps://github.com/appium/ruby_lib Ruby

https://github.com/appium/python-client Python

https://github.com/appium/java-client Java

https://github.com/admc/wd JavaScript (Node.js)

https://github.com/appium/selenium-objective-c Objective C

https://github.com/appium/php-client PHP

https://github.com/appium/appium-dotnet-driver C# (.NET)

http://github.com/appium/perl-client Perl https://github.com/jollychang/robotframework-appiumlibrary

RobotFramework

Page 20: Appium solution

20Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Appium GUI

Page 21: Appium solution

21Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Requirements

IOS Mac OSX 10.7 XCode 4.5 Command Line Tools

Android Mac OSX 10.7 or Windows 7 or Linux Android SDK

Firefox Firefox OS Simulator

Page 22: Appium solution

22

Supported Platforms

IOS Android FirefoxOS Is it True ?!

Page 23: Appium solution

23Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Smile 1

Page 24: Appium solution

24

IOS

Versions: 6.0, 6.1, 7.0, 7.1, 8.0, and 8.1 Devices: iPhone Simulator, iPad Simulator, and real iPhones and

iPads Native app support: Yes Mobile web support: Yes, via automation of mobile Safari.  Hybrid support: Yes.  Support for automating multiple apps in one session: No Support for automating multiple devices simultaneously: No

Page 25: Appium solution

25

Android

Versions: 2.3 and up Devices: Android emulators and real Android devices Native app support: Yes Mobile web support: Yes Hybrid support: Yes Support for automating multiple apps in one session: Yes Support for automating multiple devices simultaneously: Yes

Page 26: Appium solution

26

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

NPM

Page 27: Appium solution

27

SauceLabs

Automated testing in the cloud for CI. Provides the world’s largest cross-browser grid for executing

Selenium & Appium WebDriver tests

Page 28: Appium solution

28

SauceLabs – Username & Access Key

Page 29: Appium solution

29

SauceLabs - Setuppublic class AppiumDriverTest {

private AppiumDriver driver;

@Parameters({"username", "key", "os", "browser", "browserVersion"}) @BeforeMethod public void setUp(@Optional("nael_sl") String username, @Optional("e8ea754d-c8a0-488f-993c-15f583ab2179") String key, @Optional("mac") String os, @Optional("iphone") String browser, @Optional("5.0") String browserVersion, Method method) throws Exception {

// Choose the browser, version, and platform to test DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setBrowserName(browser); capabilities.setCapability("version", browserVersion); capabilities.setCapability("platform", Platform.valueOf(os)); capabilities.setCapability("name", method.getName()); // Create the connection to Sauce Labs to run the tests this.driver = new RemoteWebDriver(new URL("http://" + username + ":" + key + "@ondemand.saucelabs.com:80/wd/hub"),capabilities); }

@Test public void webDriver() throws Exception { // Make the browser get the page and check its title driver.get("http://www.amazon.com/"); assertEquals("Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more", driver.getTitle()); }

}

Page 30: Appium solution

30

AUTOMATED TEST CONFIGURATOR

Page 31: Appium solution

31

AUTOMATED TEST CONFIGURATOR

Page 32: Appium solution

32

AUTOMATED TEST CONFIGURATOR

Page 33: Appium solution

33

AUTOMATED TEST CONFIGURATOR

Page 34: Appium solution

34

AUTOMATED TEST CONFIGURATOR

Page 35: Appium solution

35

AUTOMATED TEST CONFIGURATOR

Page 36: Appium solution

36

AUTOMATED TEST CONFIGURATOR

Page 37: Appium solution

37

New Locator Strategies

Page 38: Appium solution

38

Webviews

Page 39: Appium solution

39

Capabilities

New capability structure - Will be adopted for Selenium 4 - platformName, platformVersion, deviceName, app - platformName, platformVersion, deviceName, browserName

autoWebview (Android) avdLaunchTimeout, avdReadyTimeout (Android) unicodeKeyboard (iOS) sendKeyStrategy

- “oneByOne”, “grouped”, “setValue”

Page 40: Appium solution

40

TouchActions

Page 41: Appium solution

41

MultiTouchActions

Page 42: Appium solution

42

Requirements - Java

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

Dependency (Maven) Android SDK TestNG/Junit Emulator/ Real Device Appium Server Node.js (If running appium from source) Mac OS X 10.7 or higher XCode >= 4.6.3 Apple Developer Tools (iPhone simulator SDK, command line tools) Homebrew Node and npm

Page 43: Appium solution

43

Configurations

Environment Variables & Path Settings JAVA_HOME ANDROID_HOME MAVEN_HOME

Android Platform Version 4.2+ must be installed

Page 44: Appium solution

44

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 45: Appium solution

45

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);    }

Page 46: Appium solution

46

Smile 2

Page 47: Appium solution

47

Java JDK

Download java JDK :www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

to add new variable and edit the path. right click on computer - > properties -> Advanced system settings -> Environment variablesAdd new variable : New : variable name : JAVA_HOME variable value : C:\Program Files\Java\jdk1.7.0_79

Edit Path : ;C:\Program Files\Java\jdk1.7.0_79\bin

Page 48: Appium solution

48

Download Eclipse ( with TestNG & Maven)

www.eclipse.org Add TestNG plugin : Help -> install new software -> Add -> Name : TestNG

Location : http://beust.com/eclipse Add Maven : Help -> install new software -> Add -> Name : Maven Location : http://download.eclipse.org/technology/m2e/releases

Page 49: Appium solution

49

ADT Plugin

ADT Plugin ( Android Developer Tools) :

Help -> install new software -> Add -> Name : ADT Plugin Location : https://dl-ssl.google.com/android/eclipse/

Page 50: Appium solution

50

Android SDK

Android SDK ( Software Developer Kit) :developer.android.com/sdk/index.html

To add the location of the android sdk folder to eclipse :Window -> Preferences -> Android

SDK Location : the path of the android-sdks

Page 51: Appium solution

51

ANDROID_HOME

to add new variable and edit the path. right click on computer - > properties -> Advanced system settings -> Environment variablesAdd new variable : New : variable name : ANDROID_HOME variable value : path\android -sdks

Edit Path : ; path\android –sdks\platform-toolsEdit Path : ; path\android –sdks\tools

Page 52: Appium solution

52

Appium

Install Appium server : http://appium.io/downloads.html

Download Appium and Selenium jars from Maven repositories

Selenium : http://www.seleniumhq.org/download/Java-client : https://search.maven.org/#search%7Cga%7C1%7Cjava-client

Page 53: Appium solution

53

AndroidDriver driver=new AndroidDriver(new

URL("http://127.0.0.1:4723/wd/hub"),cap );

File app = new File(appDir, “Rounds.apk");

Page 54: Appium solution

54

Inspect Elements

Native app : Android : uiautomatorviewer tool that is located in the android-sdks/tools.

IOS : Appium Inspector that is located with the appium server. Web & Hybrid apps :

Chrome://inspect/#devices

* In hybrid apps should pay attention to switch between drivers from native to web a vice versa.

Page 55: Appium solution

55

Scenario on Rounds App

Page 56: Appium solution

56

Inspectors

Android UIautomatorviewer / IOS UIautomation - A GUI tool to scan and analyze the UI components of an Android/IOS application.

Page 57: Appium solution

57Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Drivers Relationship

Page 58: Appium solution

58Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Web driver FW Design

Page 59: Appium solution

59Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Appium Design

Page 60: Appium solution

60Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Current FW

Page 61: Appium solution

61Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Report

Page 62: Appium solution

62Confidential and propriety Galil Software, Ltd. 2012

25.12.11

Thank You Nael Abd Aljawad – QA Automation Technical Leader