Merge pull request #2203 from Jonahss/LocStratUnderscores

Loc strat underscores
This commit is contained in:
Jonathan Lipps
2014-03-27 16:19:39 -07:00
8 changed files with 26 additions and 25 deletions

View File

@@ -10,7 +10,8 @@ Appium supports a subset of the WebDriver locator strategies:
Appium additionally supports some of the [Mobile JSON Wire Protocol](https://code.google.com/p/selenium/source/browse/spec-draft.md?repo=mobile) locator strategies
* `-ios_uiautomation`: a string corresponding to a recursive element search using the UIAutomation library (iOS-only)
* `-ios uiautomation`: a string corresponding to a recursive element search using the UIAutomation library (iOS-only)
* `accessibility id`: a string corresponding to a recursive element search using the Id/Name that the native Accessibility options utilize.
###Tag name mapping
@@ -122,12 +123,12 @@ Python:
driver.find_elements_by_tag_name('tableCell')[5].click()
```
### Using the -ios_uiautomation locator strategy
### Using the "-ios uiautomation" locator strategy
WD.js:
```js
driver.element('-ios_uiautomation', '.elements()[1].cells()[2]').getAttribute('name');
driver.element('-ios uiautomation', '.elements()[1].cells()[2]').getAttribute('name');
```
# FindAndAct<a name="findandact"></a>

View File

@@ -66,7 +66,7 @@ androidController.findUIElementOrElements = function (strategy, selector, many,
}
}
if (strategy === "name") {
helpers.logDeprecationWarning("Locator strategy", '"name"', '"accessibility_id"');
helpers.logDeprecationWarning("Locator strategy", '"name"', '"accessibility id"');
}
var doFind = function (findCb) {
this.proxy(["find", params], function (err, res) {

View File

@@ -10,7 +10,7 @@ public enum Strategy {
CLASS_NAME(0, "class name"), CSS_SELECTOR(1, "css selector"), ID(2, "id"), NAME(
3, "name"), LINK_TEXT(4, "link text"), PARTIAL_LINK_TEXT(5,
"partial link text"), TAG_NAME(6, "tag name"), XPATH(7, "xpath"), DYNAMIC(
8, "dynamic"), ACCESSIBILITY_ID(9, "accessibility_id");
8, "dynamic"), ACCESSIBILITY_ID(9, "accessibility id");
public static Strategy fromString(final String text) throws InvalidStrategyException {
if (text != null) {

View File

@@ -205,12 +205,12 @@ exports.checkValidLocStrat = function (strat, includeWeb, cb) {
'xpath',
'id',
'name',
'accessibility_id',
'accessibility id',
'dynamic',
'class name'
];
var nativeStrats = [
'-ios_uiautomation'
'-ios uiautomation'
];
var webStrats = [
'link text',
@@ -223,7 +223,7 @@ exports.checkValidLocStrat = function (strat, includeWeb, cb) {
var webDeprecations = {
};
var deprecations = {};
if (includeWeb) {
validStrats = validStrats.concat(webStrats);
deprecations = webDeprecations;

View File

@@ -35,10 +35,10 @@ iOSController.createGetElementCommand = function (strategy, selector, ctx, many)
var command = "";
switch (strategy) {
case "name":
helpers.logDeprecationWarning("Locator Strategy", '"name"', '"accessibility_id"');
helpers.logDeprecationWarning("Locator Strategy", '"name"', '"accessibility id"');
command = ["au.getElement", ext, "ByName('", selector, "'", ctx, ")"].join('');
break;
case "accessibility_id":
case "accessibility id":
command = ["au.getElement", ext, "ByName('", selector, "'", ctx, ")"].join('');
break;
case "xpath":
@@ -52,7 +52,7 @@ iOSController.createGetElementCommand = function (strategy, selector, ctx, many)
"PredicateWeighted(\"name contains[c] '", selector, "' || label contains[c] '",
selector, "' || value contains[c] '", selector, "'\");"].join('');
break;
case "-ios_uiautomation":
case "-ios uiautomation":
command = ["au.getElement", ext, "ByUIAutomation('", selector, "'", ctx, ")"].join('');
break;
default:

View File

@@ -89,8 +89,8 @@ IOS.prototype.init = function () {
this.curWebCoords = null;
this.onPageChangeCb = null;
this.dontDeleteSimApps = false;
this.supportedStrategies = ["name", "tag name", "xpath", "id", "-ios_uiautomation",
"class name", "accessibility_id"];
this.supportedStrategies = ["name", "tag name", "xpath", "id", "-ios uiautomation",
"class name", "accessibility id"];
this.localizableStrings = {};
this.keepAppToRetainPrefs = false;
};

View File

@@ -167,14 +167,14 @@ describe("apidemo - find elements -", function () {
});
});
describe('find elements using accessibility_id locator strategy', function () {
describe('find elements using accessibility id locator strategy', function () {
it('should find an element by name', function (done) {
driver.element('accessibility_id', 'Animation').then(function (el) {
driver.element('accessibility id', 'Animation').then(function (el) {
el.should.exist;
}).nodeify(done);
});
it('should return an array of one element if the plural "elements" is used', function (done) {
driver.elements('accessibility_id', 'Animation').then(function (els) {
driver.elements('accessibility id', 'Animation').then(function (els) {
els.length.should.equal(1);
}).nodeify(done);
});
@@ -189,9 +189,9 @@ describe("apidemo - find elements -", function () {
});
});
describe('invalid locator strategy', function () {
it('should not accept -ios_uiautomation locator strategy', function (done) {
it('should not accept -ios uiautomation locator strategy', function (done) {
driver
.elements('-ios_uiautomation', '.elements()').catch(function (err) {
.elements('-ios uiautomation', '.elements()').catch(function (err) {
throw JSON.stringify(err.cause.value);
})
.should.be.rejectedWith(/The requested resource could not be found/)

View File

@@ -66,26 +66,26 @@ describe('uicatalog - find element -', function () {
}).nodeify(done);
});
describe('find elements using accessibility_id locator strategy', function () {
describe('find elements using accessibility id locator strategy', function () {
it('should find an element by name', function (done) {
driver.element('accessibility_id', 'UICatalog').then(function (el) {
driver.element('accessibility id', 'UICatalog').then(function (el) {
el.should.exist;
}).nodeify(done);
});
it('should find a deeply nested element by name', function (done) {
driver.element('accessibility_id', 'UINavigationBarBackIndicatorDefault.png').then(function (el) {
driver.element('accessibility id', 'Toolbar, Uses of UIToolbar').then(function (el) {
el.should.exist;
}).nodeify(done);
});
it('should find an element by name beneath another element', function (done) {
driver.element('accessibility_id', 'Empty list').then(function (el) {
el.element('accessibility_id', 'Controls, Various uses of UIControl').then(function (innerEl) {
driver.element('accessibility id', 'Empty list').then(function (el) {
el.element('accessibility id', 'Controls, Various uses of UIControl').then(function (innerEl) {
innerEl.should.exist;
}).nodeify(done);
});
});
it('should return an array of one element if the plural "elements" is used', function (done) {
driver.elements('accessibility_id', 'UICatalog').then(function (els) {
driver.elements('accessibility id', 'UICatalog').then(function (els) {
els.length.should.equal(1);
}).nodeify(done);
});
@@ -207,7 +207,7 @@ describe('uicatalog - find element -', function () {
});
describe('FindElement(s)ByUIAutomation', function () {
var byUIA = '-ios_uiautomation';
var byUIA = '-ios uiautomation';
// Running sequentially cause parallel runs crash appium
var filterDisplayed = function (els) {