Skip to content

Commit

Permalink
ensure we can use appium 1.0 style launch information from the comman…
Browse files Browse the repository at this point in the history
…d line (fix appium#2231)
  • Loading branch information
jlipps committed Apr 4, 2014
1 parent 4175740 commit 3ae838a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
8 changes: 6 additions & 2 deletions docs/server-args.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ All flags are optional, but some are required in conjunction with certain others
|`--avd-args`|null|(Android-only) Additional emulator arguments to launch the avd|`--avd-args -no-snapshot-load`|
|`--device-ready-timeout`|5|(Android-only) Timeout in seconds while waiting for device to become ready|`--device-ready-timeout 5`|
|`--safari`|false|(IOS-Only) Use the safari app||
|`--device-name`|null|(IOS-Simulator-only) name of the iOS device to use|`--device-name iPhone Retina (4-inch)`|
|`--device-name`|null|Name of the mobile device to use|`--device-name iPhone Retina (4-inch), Android Emulator`|
|`--platform-name`|null|Name of the mobile platform: iOS, Android, or FirefoxOS|`--platform-name iOS`|
|`--platform-version`|null|Version of the mobile platform|`--platform-version 7.1`|
|`--automation-name`|null|Name of the automation tool: Appium or Selendroid|`--automation-name Appium`|
|`--browser-name`|null|Name of the mobile browser: Safari or Chrome|`--browser-name Safari`|
|`--default-device`, `-dd`|false|(IOS-Simulator-only) use the default simulator that instruments launches on its own||
|`--force-iphone`|false|(IOS-only) Use the iPhone Simulator no matter what the app wants||
|`--force-ipad`|false|(IOS-only) Use the iPad Simulator no matter what the app wants||
Expand All @@ -56,7 +60,7 @@ All flags are optional, but some are required in conjunction with certain others
|`--selendroid-port`|8080|Local port used for communication with Selendroid|`--selendroid-port 8080`|
|`--chromedriver-port`|9515|Port upon which ChromeDriver will run|`--chromedriver-port 9515`|
|`--use-keystore`|false|(Android-only) When set the keystore will be used to sign apks.||
|`--keystore-path`|/Users/saucelabs/.android/debug.keystore|(Android-only) Path to keystore||
|`--keystore-path`|/Users/user/.android/debug.keystore|(Android-only) Path to keystore||
|`--keystore-password`|android|(Android-only) Password to keystore||
|`--key-alias`|androiddebugkey|(Android-only) Key alias||
|`--key-password`|android|(Android-only) Key password||
Expand Down
11 changes: 7 additions & 4 deletions lib/appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Appium.prototype.getDeviceType = function (args, caps) {
}
throw new Error("Could not determine your device from Appium arguments " +
"or desired capabilities. Please make sure to specify the " +
"'device' capability");
"'deviceName' capability");
};

Appium.prototype.getDeviceTypePreMJSONWP = function (args, caps) {
Expand All @@ -133,9 +133,12 @@ Appium.prototype.getDeviceTypePreMJSONWP = function (args, caps) {
};

Appium.prototype.getDeviceFromMJSONWP = function (args, caps) {
var platform = caps.platformName ? caps.platformName.toString().toLowerCase() : '';
var browser = caps.browserName ? caps.browserName.toString().toLowerCase() : '';
var automation = caps.automationName ? caps.automationName.toString().toLowerCase() : '';
var platform = caps.platformName || args.platformName;
platform = platform ? platform.toString().toLowerCase() : '';
var browser = caps.browserName || args.browserName;
browser = browser ? browser.toString().toLowerCase() : '';
var automation = caps.automationName || args.automationName;
automation = automation ? automation.toString().toLowerCase() : '';

var validPlatforms = ['ios', 'android', 'firefoxos'];
if (platform && !_.contains(validPlatforms, platform)) {
Expand Down
36 changes: 34 additions & 2 deletions lib/server/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,40 @@ var args = [
dest: 'deviceName'
, defaultValue: null
, required: false
, example: "iPhone Retina (4-inch)"
, help: "(IOS-Simulator-only) name of the iOS device to use"
, example: "iPhone Retina (4-inch), Android Emulator"
, help: "Name of the mobile device to use"
}],

[['--platform-name'], {
dest: 'platformName'
, defaultValue: null
, required: false
, example: "iOS"
, help: "Name of the mobile platform: iOS, Android, or FirefoxOS"
}],

[['--platform-version'], {
dest: 'platformVersion'
, defaultValue: null
, required: false
, example: "7.1"
, help: "Version of the mobile platform"
}],

[['--automation-name'], {
dest: 'automationName'
, defaultValue: null
, required: false
, example: "Appium"
, help: "Name of the automation tool: Appium or Selendroid"
}],

[['--browser-name'], {
dest: 'browserName'
, defaultValue: null
, required: false
, example: "Safari"
, help: "Name of the mobile browser: Safari or Chrome"
}],

[['--default-device', '-dd'], {
Expand Down
8 changes: 8 additions & 0 deletions test/unit/configuration-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ describe('Appium', function () {
[{}, {platformName: 'iOS'}, 'ios'],
, [{}, {platformName: 'Android'}, 'android']
, [{}, {platformName: 'FirefoxOS'}, 'firefoxos']
, [{platformName: 'Android'}, {}, 'android']
, [{platformName: 'ios'}, {}, 'ios']
, [{platformName: 'iOS'}, {platformName: 'android'}, 'android']
];
_.each(deviceCapabilities, function (test) {
assertCapsGiveCorrectDevices(appium, test);
Expand All @@ -93,6 +96,8 @@ describe('Appium', function () {
, [{}, {platformName: 'Android', browserName: 'Chrome'}, 'chrome']
, [{}, {platformName: 'Android', browserName: 'Chromium'}, 'chrome']
, [{}, {platformName: 'Android', browserName: 'browser'}, 'chrome']
, [{browserName: 'browser'}, {platformName: 'Android'}, 'chrome']
, [{browserName: 'Safari'}, {platformName: 'ios'}, 'safari']
];
_.each(browserCapabilities, function (test) {
assertCapsGiveCorrectDevices(appium, test);
Expand All @@ -103,6 +108,9 @@ describe('Appium', function () {

var automationCapabilities = [
[{}, {automationName: 'selendroid', platformName: 'Android'}, 'selendroid']
, [{automationName: 'selendroid'}, {platformName: 'Android'}, 'selendroid']
, [{automationName: 'selendroid'}, {automationName: 'appium', platformName: 'android'}, 'android']
, [{automationName: 'appium'}, {platformName: 'Android'}, 'android']
];
_.each(automationCapabilities, function (test) {
assertCapsGiveCorrectDevices(appium, test);
Expand Down

0 comments on commit 3ae838a

Please sign in to comment.