Appium workship, Mobile Web+Dev Conference

Post on 16-Jul-2015

221 views 2 download

Tags:

Transcript of Appium workship, 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

Appium Workshop

Jonathan Lipps • Director of Ecosystem & Integrations • Sauce Labs

@AppiumDevs • @jlipps • @saucelabs

Ecosystem &Integrations

Core Developer

appium introduction

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

appium is open source

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

appium philosophy

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!

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

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.

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

appium architecture

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

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

appium extends the WebDriver protocol with mobile-specific behaviors

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

appium setup

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

Sauce Requirements !

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

Workshop Requirements !

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

code: mobilewebdevcon15

Sauce Access Key !

https://saucelabs.com/account

Node !

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

Node Package Manager !

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

Fork and clone the repo! !

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

Install the necessary modules !

- cd javascript-workshop- npm install

Set up credentials:Mac !

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

Windows !

SetX SAUCE_USERNAME meeee SetX SAUCE_ACCESS_KEY xxxxxxx

Set up credentials: Easy/Insecure !

tests/functional/helpers/setup.js

appium concepts

Types of tests !

- Native - Hybrid - Mobile Web

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

Desired Capabilities - iOS

Desired Capabilities

Sessions

Finding Elements

Finding Elements

Interacting with Elements

Interacting with WebViews

Interacting with WebViews

Interacting with the Device

Gestures

Waits

appium hands-on

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

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

Further problems?

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

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

Run tests in parallel

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

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

Cross-platform tests

Cross-platform tests

Building your app model

Building your app model

Building your app model (web)

Building your app model (web, cont'd)

Debugging Failures !

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

Appium bugs? Oh noes! !

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

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!

Thank you!

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

@AppiumDevs • @imurchie • @saucelabs