Top Banner
automation for mobile apps Adam Christian | @admc | Sauce Labs JSConf Workshop Wednesday, May 29, 13
37

automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Jun 10, 2018

Download

Documents

dinhkhuong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

automation for mobile apps

Adam Christian | @admc | Sauce Labs

JSConf Workshop

Wednesday, May 29, 13

Page 2: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

appium is the cross-platform solution for native and hybrid mobile automation

Wednesday, May 29, 13

Page 3: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

1

appium introduction

2 3 4

Wednesday, May 29, 13

Page 4: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

PhilosophyR1. Test the same app you submit to the marketplaceR2. Write your tests in any language, using any frameworkR3. Use a standard automation specification and APIR4. Build a large and thriving open-source community effort

Wednesday, May 29, 13

Page 5: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Wednesday, May 29, 13

Page 6: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Architecture• Apple Instruments & UIAutomation for iOS

• Google UiAutomator for Android (4.2.1 up)

• Selendroid for older Android & hybrid

• Selenium WebDriver interface

• More platforms coming! (FirefoxOS, etc...)

Wednesday, May 29, 13

Page 7: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Selenium WebDriver?• the standard for browser automation, with

libraries in every* language

• used every single day by thousands of developers familiar with its model

• W3C working draft

Wednesday, May 29, 13

Page 8: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

appium setup

2 3 41

Wednesday, May 29, 13

Page 9: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Requirements (1/3)• Xcode 4.6 with CLI tools and iOS 6.1

• Download Appium.app

• Node & NPM• brew install node

Wednesday, May 29, 13

Page 10: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Requirements (2/3)• Android Developer Tools >= 21• http://developer.android.com/sdk/index.html

• mv to /usr/local/adt

• export ANDROID_HOME=/usr/local/adt/sdk

• add (.bashrc, .zshrc, etc):$ANDROID_HOME/tools$ANDROID_HOME/platform-tools to $PATH

Wednesday, May 29, 13

Page 11: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Requirements (3/3)• Set up Sauce Labs demo account• export SAUCE_USERNAME=”AppiumUser”export SAUCE_PASSWORD=”appiumrocks”export SAUCE_ACCESS_KEY=”e4c82f68-cf00-40af-a8bc-5c78df0511a9”

* This is for testing the Sauce Labs demo app -- not required for using Appium.

Wednesday, May 29, 13

Page 12: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Make an Android Device

• android

• Check ‘Intel x86 Atom System Image’ - Android (4.2.2)

• Click ‘Install 1 package...’

• Tools > Manage AVDs

• New...

Wednesday, May 29, 13

Page 13: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Create the Image

• AVD Name: workshop

• Device: Nexus S

• Target: Android 4.2.2

• CPU: Intel/Atom

• Host GPU

Wednesday, May 29, 13

Page 14: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Install HAXM for Speed!

• open /usr/local/adt/sdk/extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM.dmg

Wednesday, May 29, 13

Page 15: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Launch AVD• In a new terminal window:• emulator @workshop -netfast

• Go through the new device tour

• $ANDROID_HOME/sdk/tools/emulator @workshop -netfast (without env)

Wednesday, May 29, 13

Page 16: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Get the workshop code• git clone https://github.com/appium/workshop.git appium-workshop

• cd appium-workshop

Wednesday, May 29, 13

Page 17: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Install dependencies• npm install -g mocha # test runner

• npm install . # project deps

• apps/download.sh # download apps

Wednesday, May 29, 13

Page 18: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Launch Appium

• open /Applications/Appium.app

Wednesday, May 29, 13

Page 19: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Moment of truth...• mocha -t 60000 js/ios/step1.js

• mocha -t 60000 js/android/step1.js

Also: step2 and step3

Wednesday, May 29, 13

Page 20: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

appium test model

2 3 41

Wednesday, May 29, 13

Page 21: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Start a session

Wednesday, May 29, 13

Page 22: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Find elements

Wednesday, May 29, 13

Page 23: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Interact with elements

Wednesday, May 29, 13

Page 24: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Avoid rightward drift

Wednesday, May 29, 13

Page 25: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

appium test building

2 3 41

Wednesday, May 29, 13

Page 26: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Pre-launch app to inspect

Wednesday, May 29, 13

Page 27: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Inspector helps!

Wednesday, May 29, 13

Page 28: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

vim js/ios/step1.js

Wednesday, May 29, 13

Page 29: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

uiautomatorviewer for Android

Wednesday, May 29, 13

Page 30: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

vim js/android/step1.js

Wednesday, May 29, 13

Page 31: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

appium real devices

* Device must be in developer mode with usb debugging enabled.

Wednesday, May 29, 13

Page 32: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

appium scale

Wednesday, May 29, 13

Page 33: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

appium is great for local test development, but has limitations when scaling up for use in CI

Wednesday, May 29, 13

Page 34: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Sauce Labs is great for scale when you need to run a lot of appium tests in your build

Wednesday, May 29, 13

Page 35: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

saucelabs.com/appium

Wednesday, May 29, 13

Page 36: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Run tests on Sauce

Wednesday, May 29, 13

Page 37: automation for mobile apps - Sauce Labssaucelabs.com/downloads/jsconf.pdf · automation for mobile apps ... any framework R3. Use a standard automation specification and API R4.

Thanks!

appium.iogithub.com/appium/appium

@AppiumDevs    |    @admc    |    @saucelabs

Wednesday, May 29, 13