Presentation and example of testing a hybrid mobile app with Appium
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
index.html
package.json
test.js

README.md

class: title

Testing hybrid mobile apps with Appium

Ben Godfrey
@afternoon


What is Appium?

  • Selenium for phones and tablets
  • Speaks the WebDriver protocol
  • iOS and Android
  • Test native or hybrid apps

Appium interactions

  • Tap
  • Fill in forms (type text, selects, radios, checkboxes)
  • Gestures
  • Multitouch

A simple app

Use Ionic to create a basic app.

npm install —g cordova ionic
ionic start foo tabs
cd foo
ionic platform add ios
ionic build ios
ionic emulate ios

(Use npm run createapp in the git repo.)


A simple test

// capabilities for iOS simulator
var capabilities = {
  browserName: "",
  autoWebview: true,
  platformName: "iOS",
  platformVersion: "7.1",
  deviceName: "iPhone Simulator",
  app: "/path/to/foo.app"
};

A simple test

// setup wd session
before(function(done) {
  browser = wd.promiseChainRemote(appiumServer);
  browser
    .init(capabilities)
    .then(function() { done(); });
});

A simple test

// test a very simple property of the app
it("should have title 'Dashboard'", function (done) {
  browser
    .elementByCss(".title")
    .getValue().should.become("Dashboard")
    .then(function() { done(); });
});

A simple test

// kill session after tests have run
after(function(done) {
  browser
    .quit()
    .then(function() { done(); });
});

A more exciting test

// a more exciting test
it("should have some tabs", function (done) {
  browser
    .elementByCss("a[icon~=ion-heart]")
    .click()
    .elementByCss(".title")
    .getValue().should.become("Friends")
    .elementByCss("a[icon~=ion-gear-b]")
    .click()
    .elementByCss(".title")
    .getValue().should.become("Account")
    .then(function() { done(); });
});

Run tests

git clone git@github.com:afternoon/testing-hybrid-apps-with-appium.git
cd testing-hybrid-apps-with-appium
npm install
appium & # or run in separate console
npm test

Real devices

Android

  • No problems!

iOS


Test clouds

Provider Note
TestDroid Lots of real devices
Saucelabs Emulators
Appthwack Some real devices, had issues

How should I organise my Appium tests?

  • JavaScript is not the only choice
  • Jasmine, Mocha, Cucumber
  • Page objects

Thanks!

You should follow @wongatech.