Install and upgrade pip on Mac OS X

Mac OS X latest Yosemite comes with Python version 2.7, but not with pip (package manager). If you have Command Line Tools installed, the installation of pip is very simple.

Installation

# install command line tools (if not installed)
$ xcode-select --install

# install pip via easy_install
$ sudo easy_install pip

# show current pip version (optional)
$ pip --version

Upgrade

# show current pip version (optional)
$ pip --version

# upgrade pip
$ sudo pip install --upgrade pip

In case you need to install and manage different versions of Python, I can recommend to read this article.

Small helper for iOS automated test 2

The second part of this small series, it shows how to obtaining device property informations.

Helper

var Device = {
  isIPhone: function() {
    return this.target().model().match("iPhone");
  },
  isIPad: function() {
    return this.target().model().match("iPad");
  },
  isName: function() {
    return this.target().name();
  },
  isSystemName: function() {
    return this.target().systemName();
  },
  isSystemVersion: function() {
    return this.target().systemVersion();
  },
  target: function() {
    return UIATarget.localTarget();
  }
};

Example

var message = Device.isName();
UIALogger.logMessage("Name: " + message);

var message = Device.isSystemName();
UIALogger.logMessage("SystemName: " + message);

var message = Device.isSystemVersion(); UIALogger.logMessage("SystemVersion: " + message);

if (!Device.isIPad()) {
  throw new Error("Test suite only works on iPad");
}

Small helper for iOS automated test

Create test cases on the fly

Helper

function runTestcase(description, teststeps) {
  try {
    UIALogger.logStart(description);
    teststeps();
    UIALogger.logPass("Testcase passed");
  } catch (exception) {
    UIALogger.logError(exception.message);
    target.logElementTree();
    UIALogger.logFail("Testcase failed");
    throw exception;
  }
}

Example

var target = UIATarget.localTarget();
var app = target.frontMostApp();
var window = app.mainWindow();

runTestcase("Press register button", function() {
  var expected = "register button";
  var register_btn = window.buttons()["Register"];
  if (!register_btn.isValid()) {
    throw new Error("not found: '" + expected + "'");
  } else {
    register_btn.tap();
  }
});