diff --git a/lib/appium.js b/lib/appium.js index 08fd19a07..95516f2c9 100644 --- a/lib/appium.js +++ b/lib/appium.js @@ -28,6 +28,10 @@ class AppiumDriver extends BaseDriver { getDriverForCaps (caps) { // TODO if this logic ever becomes complex, should probably factor out // into its own file + if (!caps.platformName || !_.isString(caps.platformName)) { + throw new Error("You must include a platformName capability"); + } + if (caps.platformName.toLowerCase() === "fake") { return FakeDriver; } @@ -39,7 +43,8 @@ class AppiumDriver extends BaseDriver { if (caps.platformName.toLowerCase() === 'ios') { return IosDriver; } - throw new Error("Could not find a driver for those caps"); + throw new Error("Could not find a driver for those caps. Please double-" + + "check your platformName capability"); } async getStatus () { diff --git a/test/driver-specs.js b/test/driver-specs.js index 346ecb359..3a24fbbc5 100644 --- a/test/driver-specs.js +++ b/test/driver-specs.js @@ -123,5 +123,11 @@ describe('AppiumDriver', () => { }); describe('sessionExists', () => { }); + describe('getDriverForCaps', () => { + it('should not blow up if user doesnt provide platformName', () => { + let appium = new AppiumDriver({}); + (() => { appium.getDriverForCaps({}); }).should.throw(/platformName/); + }); + }); }); });