appium-uiauto
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "appium-uiauto", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "appium uiauto ios driver", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -298,27 +298,27 @@ var au; | ||
, lookup: function (selector, ctx) { | ||
if (typeof selector === 'string') { | ||
var _ctx = this.mainApp() | ||
, elems = []; | ||
if (typeof selector !== 'string') { | ||
return null | ||
} | ||
if (typeof ctx === 'string') { | ||
_ctx = this.cache[ctx]; | ||
} else if (typeof ctx !== 'undefined') { | ||
_ctx = ctx; | ||
} | ||
var _ctx = this.mainApp() | ||
, elems = []; | ||
this.target().pushTimeout(0); | ||
if (selector === 'alert') { | ||
var alert = this.mainApp().alert(); | ||
if (alert) { | ||
elems = $(alert); | ||
} | ||
} else { | ||
elems = $(selector, _ctx); | ||
if (typeof ctx === 'string') { | ||
_ctx = this.cache[ctx]; | ||
} else if (typeof ctx !== 'undefined') { | ||
_ctx = ctx; | ||
} | ||
this.target().pushTimeout(0); | ||
if (selector === 'alert') { | ||
var alert = this.mainApp().alert(); | ||
if (alert) { | ||
elems = $(alert); | ||
} | ||
this.target().popTimeout(); | ||
return elems; | ||
} else { | ||
elems = $(selector, _ctx); | ||
} | ||
this.target().popTimeout(); | ||
return null; | ||
return elems; | ||
} | ||
@@ -344,9 +344,4 @@ | ||
, getElementByName: function (name, ctx) { | ||
var selector = ['#', name].join('') | ||
, elems; | ||
if (typeof ctx !== 'undefined') { | ||
elems = this.lookup(selector, ctx); | ||
} else { | ||
elems = this.lookup(selector); | ||
} | ||
var selector = ['#', name].join(''); | ||
var elems = this.lookup(selector, ctx); | ||
@@ -412,9 +407,4 @@ if (elems.length > 0) { | ||
, getElementsByName: function (name, ctx) { | ||
var selector = ['#', name].join('') | ||
, elems; | ||
if (typeof ctx !== 'undefined') { | ||
elems = this.lookup(selector, ctx); | ||
} else { | ||
elems = this.lookup(selector); | ||
} | ||
var selector = ['#', name].join(''); | ||
var elems = this.lookup(selector, ctx); | ||
@@ -447,10 +437,4 @@ return this._returnElems(elems); | ||
var elems = []; | ||
var elems = this.lookup(selector, ctx); | ||
if (typeof ctx !== 'undefined') { | ||
elems = this.lookup(selector, ctx); | ||
} else { | ||
elems = this.lookup(selector); | ||
} | ||
return this._returnElems(elems); | ||
@@ -460,10 +444,4 @@ } | ||
, getElementByType: function (type, ctx) { | ||
var results = []; | ||
var results = this.getElementsByType(type, ctx); | ||
if (typeof ctx !== 'undefined') { | ||
results = this.getElementsByType(type, ctx); | ||
} else { | ||
results = this.getElementsByType(type); | ||
} | ||
if (results.value.length < 1) { | ||
@@ -554,9 +532,4 @@ return { | ||
, getElementByXpath: function (xpath, ctx) { | ||
var results = []; | ||
if (typeof ctx !== 'undefined') { | ||
results = this.getElementsByXpath(xpath, ctx); | ||
} else { | ||
results = this.getElementsByXpath(xpath); | ||
} | ||
var results = this.getElementsByXpath(xpath, ctx); | ||
@@ -563,0 +536,0 @@ if (results.value === null || results.value.length < 1) { |
@@ -89,9 +89,25 @@ /* | ||
}; | ||
function _getElementsByType(current, type, foundEls, isParent) { | ||
if (!isParent && current.isType(type)) { | ||
var isDuplicate = false; | ||
if (type === 'textfield') { | ||
// fixing duplicated text fields | ||
$.each(current.elements(), function (idx, child) { | ||
isDuplicate = isDuplicate || child.isType(type) && child.name() === current.name(); | ||
}); | ||
} | ||
if (!isDuplicate) foundEls.push(current); | ||
} | ||
$.each(current.elements(), function (idx, child) { | ||
_getElementsByType(child, type, foundEls, false); | ||
}); | ||
} | ||
UIAElement.prototype.getElementsByType = function (type) { | ||
return $.map(this.elements(), function (el) { | ||
var matches = el.getElementsByType(type); | ||
if (el.isType(type)) matches.unshift(el); | ||
return matches; | ||
}); | ||
var foundEls = []; | ||
_getElementsByType(this, type, foundEls, true); | ||
return foundEls; | ||
}; | ||
UIAElement.prototype.isType = function (type) { | ||
@@ -98,0 +114,0 @@ var thisType = this.toString().split(" ")[1]; |
@@ -103,2 +103,6 @@ "use strict"; | ||
summary: 'Target provided for a move action is out of bounds.' | ||
}, | ||
NoSuchContext: { | ||
code: 35, | ||
summary: 'No such context found.' | ||
} | ||
@@ -105,0 +109,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74646
2296