mirror of
https://github.com/appium/appium.git
synced 2026-02-12 04:50:08 -06:00
Add deprecation warnings for class name, tag name locator strategies. Deprecations warnings will now be thrown for: * 'tag name' in the native context * 'class name' in the native context * 'class name' in the web context 'class_name' is now a valid locator strategy for checkValidLocStrat Add test for new class name locator rename createCommand createGetElementCommand Adding unit tests for new exception throwing Add test for incorrect UIA class names
77 lines
3.3 KiB
JavaScript
77 lines
3.3 KiB
JavaScript
"use strict";
|
|
|
|
var chai = require('chai')
|
|
, should = chai.should
|
|
, controller = require('../../lib/devices/ios/ios-controller.js')
|
|
, createGetElementCommand = controller.createGetElementCommand
|
|
, getSelectorForStrategy = controller.getSelectorForStrategy;
|
|
|
|
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');
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}); |