mirror of
https://github.com/appium/appium.git
synced 2026-02-13 21:39:49 -06:00
Merge pull request #5770 from jlipps/1.5
don't let getDriverForCaps blow up mysteriously on forgotten platformName
This commit is contained in:
@@ -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 () {
|
||||
|
||||
@@ -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/);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user