Skip to content

Commit

Permalink
Add ability to use automationName XCUITest
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Jun 22, 2016
1 parent 9c663cf commit 5a67708
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
12 changes: 9 additions & 3 deletions lib/appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion test/driver-e2e-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('FakeDriver - via HTTP', () => {
});
after(async () => {
if (server) {
await B.promisify(server.close.bind(server))();
await server.close();
}
});

Expand Down
13 changes: 12 additions & 1 deletion test/driver-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
});
});
});
});

0 comments on commit 5a67708

Please sign in to comment.