appium mobile web+dev conference

63
mobile automation made awesome Isaac A. Murchie Software Developer, Ecosystem & Integrations Sauce Labs @AppiumDevs @imurchie @saucelabs MOBILE+WEB DEVCON 2014 San Francisco, CA February 3, 2015 link???

Upload: isaac-murchie

Post on 16-Jul-2015

96 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Appium   mobile web+dev conference

mobile automation made awesome

Isaac A. Murchie • Software Developer, Ecosystem & Integrations • Sauce Labs

@AppiumDevs • @imurchie • @saucelabs

MOBILE+WEB DEVCON 2014 • San Francisco, CAFebruary 3, 2015

link???

Page 2: Appium   mobile web+dev conference

Appium Workshop

Jonathan Lipps • Director of Ecosystem & Integrations • Sauce Labs

@AppiumDevs • @jlipps • @saucelabs

Ecosystem &Integrations

Core Developer

Page 3: Appium   mobile web+dev conference

appium introduction

Page 4: Appium   mobile web+dev conference

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

Page 5: Appium   mobile web+dev conference

appium is open source

Page 6: Appium   mobile web+dev conference

Over 5,500 commits

1,869 stars1,385 forksOver 160 contributors

1,700 pull requests merged2,000 issues closed

OSS Rookie of the Year, Bossie award

Over 70 releases

Page 7: Appium   mobile web+dev conference

appium philosophy

Page 8: Appium   mobile web+dev conference

Real App Under TestYou should not have to modify or recompile your application in order to test it.No discrepancy between test version and marketplace version.Ship a binary that passes tests!

Page 9: Appium   mobile web+dev conference

Language AgnosticLike Ruby? Write tests in Ruby.Like JavaScript? Write tests in JavaScript.…You get the picture.

Page 10: Appium   mobile web+dev conference

Don’t Reinvent the WheelA mobile automation framework ought to make use of the tools that are out there, rather than building everything from scratch.This goes for API as well.

Page 11: Appium   mobile web+dev conference

Open SourceIn spirit and practice, as well as in name.

Page 12: Appium   mobile web+dev conference

appium architecture

Page 13: Appium   mobile web+dev conference

Automation OrchestraApple Instruments & UIAutomation for iOSGoogle UiAutomator for Android (4.2.1 up)Google Instrumentation for older Android & hybrid (via Selendroid)WebDriver interface

Page 14: Appium   mobile web+dev conference

appium is a Node.js HTTP server that creates and handles WebDriver sessions

Page 15: Appium   mobile web+dev conference

appium extends the WebDriver protocol with mobile-specific behaviors

Page 16: Appium   mobile web+dev conference

appium can run on your computer, in your network, or on a cloud service like Sauce Labs

Page 17: Appium   mobile web+dev conference
Page 18: Appium   mobile web+dev conference

appium setup

Page 19: Appium   mobile web+dev conference

Local Requirements !

- Mac 10.9+ with Xcode and iOS SDK - Android SDK with emulators - Node.js + NPM - Java - Appium client in your language - Test runner in your language

Page 20: Appium   mobile web+dev conference

Sauce Requirements !

- Appium client in your language - Test runner in your language - Sauce Labs account

Page 21: Appium   mobile web+dev conference

Workshop Requirements !

- Sauce Labs username + access key - Node.js or io.js - npm - grunt

Page 22: Appium   mobile web+dev conference

code: mobilewebdevcon15

Page 23: Appium   mobile web+dev conference

Sauce Access Key !

https://saucelabs.com/account

Page 24: Appium   mobile web+dev conference

Node !

- http://nodejs.org/ - brew install node - node --version - ought to be v0.10.x

Page 25: Appium   mobile web+dev conference

Node Package Manager !

- https://www.npmjs.com/ - should be installed with Node - npm --version - ought to be 2.1.18 or greater

Page 26: Appium   mobile web+dev conference

Fork and clone the repo! !

git clone https://github.com/appium/javascript-workshop.git

Page 27: Appium   mobile web+dev conference

Install the necessary modules !

- cd javascript-workshop- npm install

Page 28: Appium   mobile web+dev conference

Set up credentials:Mac !

export SAUCE_USERNAME=“meeee” export SAUCE_ACCESS_KEY=“xxxxxxx”

Windows !

SetX SAUCE_USERNAME meeee SetX SAUCE_ACCESS_KEY xxxxxxx

Page 29: Appium   mobile web+dev conference

Set up credentials: Easy/Insecure !

tests/functional/helpers/setup.js

Page 30: Appium   mobile web+dev conference

appium concepts

Page 31: Appium   mobile web+dev conference

Types of tests !

- Native - Hybrid - Mobile Web

Page 32: Appium   mobile web+dev conference

Appium client for JavaScript !

- We will use wd - https://github.com/admc/wd- The official, selenium-webdriver module does not have the Appium extensions- webdriver.io is also an option, but we won’t cover it

Page 33: Appium   mobile web+dev conference

Desired Capabilities - iOS

Page 34: Appium   mobile web+dev conference

Desired Capabilities

Page 35: Appium   mobile web+dev conference

Sessions

Page 36: Appium   mobile web+dev conference

Finding Elements

Page 37: Appium   mobile web+dev conference

Finding Elements

Page 38: Appium   mobile web+dev conference

Interacting with Elements

Page 39: Appium   mobile web+dev conference

Interacting with WebViews

Page 40: Appium   mobile web+dev conference

Interacting with WebViews

Page 41: Appium   mobile web+dev conference

Interacting with the Device

Page 42: Appium   mobile web+dev conference

Gestures

Page 43: Appium   mobile web+dev conference

Waits

Page 44: Appium   mobile web+dev conference

appium hands-on

Page 45: Appium   mobile web+dev conference

Run the tests!grunt test:all # go to https://saucelabs.com/tests to see them running!

Page 46: Appium   mobile web+dev conference

Problems? Run just one test

SAUCE=1 DEVICE=ios:7.1 mocha -t 90000 -R spec test/functional/ios/web-specs.js

Or run just one group testgrunt test:ios or grunt test:ios:7.1 grunt test:android or grunt test:android:4.4 !// try grunt --help for a list of available tasks

Page 47: Appium   mobile web+dev conference

Further problems?

Grunt will fail fast when there are errors or warnings. Try running it with the --force options

Page 48: Appium   mobile web+dev conference

Run tests in parallelgrunt test:all:parallel grunt test:android:parallel grunt test:ios:parallel

Page 49: Appium   mobile web+dev conference
Page 50: Appium   mobile web+dev conference
Page 51: Appium   mobile web+dev conference

Run tests in parallel

Page 52: Appium   mobile web+dev conference

Explore the code-Gruntfile.js -package.json -apps

- // test apps, in case you run locally -node_modules

- // installed by `npm install` -tests

-functional -helpers

-apps.js // a list of application names -caps.js // set up test environments -setup.js // initialize tests

-common - f

-android -hybrid-specs.js -native-specs.js -web-specs.js

-ios -hybrid-specs.js -native-specs.js -web-specs.js

Page 53: Appium   mobile web+dev conference

Sauce Temporary Storagecurl -u YOUR_USERNAME:YOUR_ACCESS_KEY \ -X POST \ -H "Content-Type: application/octet-stream" \ https://saucelabs.com/rest/v1/storage/YOUR_USERNAME/TestApp7.1.app.zip?overwrite=true \ --data-binary @apps/TestApp7.1.app.zip

https://docs.saucelabs.com/reference/rest-api/#temporary-storage

Page 54: Appium   mobile web+dev conference

Cross-platform tests

Page 55: Appium   mobile web+dev conference

Cross-platform tests

Page 56: Appium   mobile web+dev conference

Building your app model

Page 57: Appium   mobile web+dev conference

Building your app model

Page 58: Appium   mobile web+dev conference

Building your app model (web)

Page 59: Appium   mobile web+dev conference

Building your app model (web, cont'd)

Page 60: Appium   mobile web+dev conference

Debugging Failures !

- Test output / exception messages - Appium logs - Logcat / IOS logs - Screenshot / videos - driver.source().print() at failure point

Page 61: Appium   mobile web+dev conference

Appium bugs? Oh noes! !

- http://discuss.appium.io - http://github.com/appium/appium/issues (with logs / repro instructions please!)

Page 62: Appium   mobile web+dev conference

Ready for more? You could: !

- Clean up test code into a View Object Model pattern - Use driver.source() to write simple tests for ApiDemos and UICatalog - Use driver.get(url) to load your web app and explore with WebDriver - Write a test for your own app!

Page 63: Appium   mobile web+dev conference

Thank you!

http://appium.iohttps://github.com/appium/appium

@AppiumDevs • @imurchie • @saucelabs