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");
}