mirror of
https://github.com/appium/appium.git
synced 2026-10-29 12:41:58 +08:00
@DylanLacey have a look at this, it's a gotcha of working with sim paths. My iOS SDK version might be '7.0', but the directory might be '7.0.3', or '7.0.3-64', so I changed this to use the directory finder from settings.js, and to throw a warning if there are multiple dirs. Unfortunately this change makes the unit tests rather impractical since it really depends on getting the status of the filesystem, so I added a new functional test and removed the unit tests. Also verified tests pass now on 6.1, 7.0, and 7.1 with these changes
87 lines
3.7 KiB
JavaScript
87 lines
3.7 KiB
JavaScript
"use strict";
|
|
|
|
var chai = require('chai')
|
|
, should = chai.should()
|
|
, sinon = require('sinon')
|
|
, SandboxedModule = require('sandboxed-module')
|
|
, fs = require('fs')
|
|
, path = require('path')
|
|
, controller_path = '../../lib/devices/ios/ios-controller.js'
|
|
, controller = require(controller_path)
|
|
, child_process = require('child_process')
|
|
, createGetElementCommand = controller.createGetElementCommand
|
|
, getSelectorForStrategy = controller.getSelectorForStrategy
|
|
, errors = require('../../lib/server/errors.js')
|
|
, NotYetImplementedError = errors.NotYetImplementedError
|
|
, status = require('../../lib/server/status.js');
|
|
|
|
describe('ios-controller', function () {
|
|
|
|
describe('#createGetElementCommand', function () {
|
|
it('should return \'GetType\' for name selection', function () {
|
|
var actual = createGetElementCommand('name', 'UIAKey', null, false);
|
|
actual.should.equal("au.getElementByName('UIAKey')");
|
|
});
|
|
it('should return \'GetType\' for xpath selection', function () {
|
|
var actual = createGetElementCommand('xpath', 'UIAKey', null, false);
|
|
actual.should.equal("au.getElementByXpath('UIAKey')");
|
|
});
|
|
it('should return \'GetType\' for id selection', function () {
|
|
var actual = createGetElementCommand('id', 'UIAKey', null, false);
|
|
var expected = "var exact = au.mainApp().getFirstWithPredicateWeighted" +
|
|
"(\"name == 'UIAKey' || label == 'UIAKey' || value == '" +
|
|
"UIAKey'\");exact && exact.status == 0 ? exact : " +
|
|
"au.mainApp().getFirstWithPredicateWeighted(\"name " +
|
|
"contains[c] 'UIAKey' || label contains[c] 'UIAKey' || " +
|
|
"value contains[c] 'UIAKey'\");";
|
|
actual.should.equal(expected);
|
|
});
|
|
it('should return \'GetType\' for tag name selection', function () {
|
|
var actual = createGetElementCommand('tag name', 'UIAKey', null, false);
|
|
actual.should.equal("au.getElementByType('UIAKey')");
|
|
});
|
|
it('should return \'GetType\' for class name selection', function () {
|
|
var actual = createGetElementCommand('class name', 'UIAKey', null, false);
|
|
actual.should.equal("au.getElementByType('UIAKey')");
|
|
});
|
|
});
|
|
describe('#getSelectorForStrategy', function () {
|
|
describe('given a class name', function () {
|
|
it('should allow UIA names', function () {
|
|
getSelectorForStrategy('class name', 'UIAKey').should.equal('UIAKey');
|
|
});
|
|
it('should return an error when given a non-uia name', function () {
|
|
var msg = "The class name selector must use full UIA class " +
|
|
"names. Try 'UIAkey' instead.";
|
|
(function () {
|
|
getSelectorForStrategy('class name', 'key');
|
|
}).should.Throw(TypeError, msg);
|
|
});
|
|
});
|
|
describe('given an id', function () {
|
|
describe('when there are no localizableStrings', function () {
|
|
beforeEach(function () {
|
|
controller.localizableStrings = {};
|
|
});
|
|
it('returns the selector if there aren\'t localizableStrings', function () {
|
|
var actual = controller.getSelectorForStrategy('id', 'someSelector');
|
|
actual.should.equal('someSelector');
|
|
});
|
|
});
|
|
describe('when there are localizableStrings', function () {
|
|
beforeEach(function () {
|
|
var locString = [{'someSelector': 'localSelector'}];
|
|
controller.localizableStrings = locString;
|
|
});
|
|
afterEach(function () {
|
|
controller.localizableStrings = {};
|
|
});
|
|
it('returns the localized string', function () {
|
|
var actual = controller.getSelectorForStrategy('id', 'someSelector');
|
|
actual.should.equal('localSelector');
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|