Add ability to use automationName XCUITest

This commit is contained in:
Isaac Murchie
2016-06-22 08:54:02 -07:00
parent 9c663cf18e
commit 5a67708df0
5 changed files with 24 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ import { FakeDriver } from 'appium-fake-driver';
import { AndroidDriver } from 'appium-android-driver';
import { IosDriver } from 'appium-ios-driver';
import { SelendroidDriver } from 'appium-selendroid-driver';
import { WebDriverAgentDriver } from 'appium-xcuitest-driver';
import B from 'bluebird';
import util from 'util';
@@ -40,9 +41,14 @@ class AppiumDriver extends BaseDriver {
}
// we don't necessarily have an `automationName` capability,
// but if we do and it is 'Selendroid', act on it
if ((caps.automationName || '').toLowerCase() === 'selendroid') {
return SelendroidDriver;
if (caps.automationName) {
if (caps.automationName.toLowerCase() === 'selendroid') {
// but if we do and it is 'Selendroid', act on it
return SelendroidDriver;
} else if (caps.automationName.toLowerCase() === 'xcuitest') {
// but if we do and it is 'XCUITest', act on it
return WebDriverAgentDriver;
}
}
if (caps.platformName.toLowerCase() === "fake") {

View File

@@ -110,7 +110,7 @@ async function main (args = null) {
await registerNode(args.nodeconfig, args.address, args.port);
}
} catch (err) {
server.close();
await server.close();
throw err;
}
logServerPort(args.address, args.port);

View File

@@ -42,6 +42,7 @@
"appium-logger": "^2.1.0",
"appium-selendroid-driver": "^1.3.4",
"appium-support": "^2.3.0",
"appium-xcuitest-driver": "^1.0.4",
"argparse": "^1.0.7",
"asyncbox": "^2.3.1",
"authorize-ios": "^1.0.4",

View File

@@ -27,7 +27,7 @@ describe('FakeDriver - via HTTP', () => {
});
after(async () => {
if (server) {
await B.promisify(server.close.bind(server))();
await server.close();
}
});

View File

@@ -7,6 +7,8 @@ import _ from 'lodash';
import sinon from 'sinon';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { WebDriverAgentDriver } from 'appium-xcuitest-driver';
chai.use(chaiAsPromised);
@@ -170,10 +172,19 @@ describe('AppiumDriver', () => {
describe('sessionExists', () => {
});
describe('getDriverForCaps', () => {
it('should not blow up if user doesnt provide platformName', () => {
it('should not blow up if user does not provide platformName', () => {
let appium = new AppiumDriver({});
(() => { appium.getDriverForCaps({}); }).should.throw(/platformName/);
});
it('should get WebDriverAgentDriver driver for automationName of XCUITest', () => {
let appium = new AppiumDriver({});
let driver = appium.getDriverForCaps({
platformName: 'iOS',
automationName: 'XCUITest'
});
driver.should.be.an.instanceof(Function);
driver.should.equal(WebDriverAgentDriver);
});
});
});
});