Skip to content

Commit

Permalink
Merge pull request appium#1664 from rockbot/master
Browse files Browse the repository at this point in the history
requires users to specify their device in their desired capabilities (fix appium#1656)
  • Loading branch information
jlipps committed Dec 20, 2013
2 parents 2df0775 + 158a4ba commit 957e39c
Showing 1 changed file with 14 additions and 36 deletions.
50 changes: 14 additions & 36 deletions lib/appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ Appium.prototype.start = function(desiredCaps, cb) {
};

Appium.prototype.getDeviceType = function(desiredCaps) {
// yay for HACKS!!

var errMsg = "A valid device type is required in the capabilities list";

if (desiredCaps.device) {
if (desiredCaps.device.toLowerCase().indexOf('iphone') !== -1) {
return "ios";
Expand All @@ -108,45 +110,16 @@ Appium.prototype.getDeviceType = function(desiredCaps) {
return "selendroid";
} else if (desiredCaps.device.toLowerCase().indexOf('firefox') !== -1) {
return "firefoxos";
} else if (desiredCaps.device.toLowerCase().indexOf('android') !== -1) {
return "android";
} else if (desiredCaps.device === "mock_ios") {
return "mock_ios";
} else {
return "android";
}
} else if (desiredCaps.app) {
if (desiredCaps.app.toLowerCase() === "safari") {
return "ios";
} else if (desiredCaps.app.toLowerCase() === "iwebview") {
return "ios";
} else if (desiredCaps.app.toLowerCase() === "chrome") {
return "android";
} else if (desiredCaps.app.toLowerCase() === "chromium") {
return "android";
}
} else if (desiredCaps.browserName) {
logger.warn("WARNING: use of browserName is deprecated. Please migrate " +
"your tests");
if (desiredCaps.browserName[0].toLowerCase() === "i") {
return "ios";
} else if (desiredCaps.browserName.toLowerCase() === "safari") {
return "ios";
} else if (desiredCaps.browserName.toLowerCase() === "iwebview") {
return "ios";
} else if (desiredCaps.browserName.toLowerCase() === "chrome") {
return "android";
} else if (desiredCaps.browserName.toLowerCase() === "chromium") {
return "android";
} else if (desiredCaps.browserName.toLowerCase().indexOf('selendroid') !== -1) {
return "selendroid";
} else {
return "android";
throw new Error(errMsg);
}
} else if (desiredCaps["app-package"] || this.args.androidPackage) {
return "android";
} else if (desiredCaps["app-activity"] || this.args.androidActivity) {
return "android";
}
return "ios";

throw new Error(errMsg);
};

Appium.prototype.isMockIos = function() {
Expand Down Expand Up @@ -200,7 +173,12 @@ Appium.prototype.configure = function(desiredCaps, cb) {
if (hasAppInCaps) {
app = desiredCaps.app;
}
this.deviceType = this.getDeviceType(desiredCaps);
try {
this.deviceType = this.getDeviceType(desiredCaps);
} catch (e) {
logger.error(e);
return cb(e);
}
if (this.isMockIos()) {
return cb();
}
Expand Down

0 comments on commit 957e39c

Please sign in to comment.