Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appium-uiauto

Package Overview
Dependencies
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appium-uiauto - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

2

package.json
{
"name": "appium-uiauto",
"version": "0.0.19",
"version": "0.0.20",
"description": "appium uiauto ios driver",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,152 +8,2 @@ /* globals codes, $ */

UIAElement.prototype.getFirstWithPredicateWeighted = function (predicate) {
var elems = this.getElementsWithPredicateWeighted(predicate);
return au._returnFirstElem($(elems));
};
UIAElement.prototype.getAllWithPredicateWeighted = function (predicate) {
var elems = this.getElementsWithPredicateWeighted(predicate);
return au._returnElems($(elems));
};
UIAElement.prototype.getElementsWithPredicateWeighted = function (predicate) {
var target = UIATarget.localTarget();
target.pushTimeout(0);
var search = predicate;
var result = {};
result.type = function () { return 'UIAElementNil'; };
result.isVisible = function () { return -1; };
function isNil(a) {
return a.length === 0 || (a.length === 1 && a[0].type() === 'UIAElementNil');
}
var searchElements = function (element) {
var results = element.secureTextFields().withPredicate(search);
var children = element.elements();
var allElements = [];
if (isNil(results)) {
results = element.textFields().withPredicate(search);
if (isNil(results)) {
results = element.buttons().withPredicate(search);
if (isNil(results)) {
results = children.withPredicate(search);
}
}
}
for (var resIdx = 0, resLen = results.length; resIdx < resLen; resIdx++) {
var tmp = results[resIdx];
if (tmp.type() !== 'UIAElementNil') {
result = tmp;
if (tmp.isVisible() === 1) {
allElements.push(result);
}
}
}
for (var a = 0, len = children.length; a < len; a++) {
searchElements(children[a]);
if (result.type() !== 'UIAElementNil' && result.isVisible() === 1) {
allElements.push(result);
}
}
return allElements;
};
var elements = searchElements(this);
var newElements = [];
for (var i = 0; i < elements.length; i++) {
if (newElements.indexOf(elements[i]) === -1) {
newElements.push(elements[i]);
}
}
target.popTimeout();
return newElements;
};
UIAElement.prototype.getFirstWithPredicate = function (predicate) {
var target = UIATarget.localTarget();
target.pushTimeout(0);
var search = predicate;
var result = {};
result.type = function () { return 'UIAElementNil'; };
result.isVisible = function () { return -1; };
var searchElements = function (element) {
var children = element.elements();
var results = children.withPredicate(search);
for (var resIdx = 0, resLen = results.length; resIdx < resLen; resIdx++) {
var tmp = results[resIdx];
if (tmp.type() !== 'UIAElementNil') {
result = tmp;
if (tmp.isVisible() === 1) {
return tmp;
}
}
}
for (var a = 0, len = children.length; a < len; a++) {
searchElements(children[a]);
if (result.type() !== 'UIAElementNil' && result.isVisible() === 1) {
return result;
}
}
return result;
};
var element = searchElements(this);
target.popTimeout();
if (element.type() === 'UIAElementNil') {
return {
status: 7,
value: {'message': 'An element could not be located on the page using the given search parameters.'}
};
}
return {
status: 0,
value: {ELEMENT: au.getId(element)}
};
};
UIAElement.prototype.getAllWithPredicate = function (predicate) {
var target = UIATarget.localTarget();
target.pushTimeout(0);
var search = predicate;
var elements = [];
var searchElements = function (element) {
var children = element.elements();
var results = children.withPredicate(search);
for (var a = 0, len = results.length; a < len; a++) {
elements.push({ELEMENT: au.getId(results[a])});
}
for (a = 0, len = children.length; a < len; a++) {
searchElements(children[a]);
}
if (elements.length === 0) {
elements = [];
}
return elements;
};
searchElements(this);
target.popTimeout();
return {
status: 0,
value: elements
};
};
UIAElement.prototype.getNameContains = function (targetName) {
return this.getFirstWithPredicate("name contains[c] '" + targetName + "' || label contains[c] '" + targetName + "'");
};
$.extend(au, {

@@ -365,4 +215,10 @@ cache: []

} else {
return "name contains[c] '" + sel + "' || label contains[c] '" + sel +
"' || value contains[c] '" + sel + "'";
// Note that we don't want to include 'value' in this search. Even
// though the documentation says the 'value' function on UIAElement
// returns a string, on the backend it can sometimes be a number
// (e.g. 0 or 1 for a switch). If this happens, UIAutomation will
// throw an exception since predicate keywords like CONTAINS and LIKE can
// only be performed on a collection/string.
return "name contains[c] '" + sel + "' || label contains[c] '" + sel
+ "'";
}

@@ -384,3 +240,3 @@ }

var pred = this._getIdSearchPredicate(sel, false);
return this.mainApp().getAllWithPredicateWeighted(pred);
return this.mainApp().getAllWithPredicate(pred);
}

@@ -387,0 +243,0 @@

@@ -215,2 +215,73 @@ /* globals $, au, codes */

UIAElement.prototype.getFirstWithPredicateWeighted = function (predicate) {
var weighting = [
'secureTextFields'
, 'textFields'
, 'buttons'
, 'elements'
];
var elems = this._elementOrElementsWithPredicateWeighted(predicate,
weighting, true);
return au._returnFirstElem($(elems));
};
UIAElement.prototype.getFirstWithPredicate = function (predicate) {
var weighting = ['elements'];
var elems = this._elementOrElementsWithPredicateWeighted(
predicate, weighting, true);
return au._returnFirstElem($(elems));
};
UIAElement.prototype.getAllWithPredicate = function (predicate) {
var weighting = ['elements'];
var elems = this._elementOrElementsWithPredicateWeighted(predicate, weighting);
return au._returnElems($(elems));
};
UIAElement.prototype._elementOrElementsWithPredicateWeighted = function (predicate, weighting, onlyFirst) {
var onlyFirst = (onlyFirst === true);
var weighting = weighting || ['elements'];
UIATarget.localTarget().pushTimeout(0);
var results = [];
var element = this;
var func, found;
$.each(weighting, function (idx, prop) {
if (typeof element[prop] === 'function') {
found = element[prop]().withPredicate(predicate)
.withValueForKey(true, 'isVisible');
} else {
throw new Error("Invalid function '" + prop + "'");
}
if (found.isValid()) {
results = results.concat(found.toArray());
}
// If we don't find anything or if we aren't just trying to find the first
// match, keep looking. Otherwise exit the loop.
return (!onlyFirst || results.length === 0);
});
// Only look through children if we have to.
if (!onlyFirst || results.length === 0) {
var child;
for (var a = 0, len = this.elements().length; a < len; a++) {
child = this.elements()[a];
results = results.concat(child
._elementOrElementsWithPredicateWeighted(predicate,
weighting, onlyFirst));
}
}
UIATarget.localTarget().popTimeout();
return results;
};
UIAElement.prototype.getNameContains = function (targetName) {
return this.getFirstWithPredicate("name contains[c] '" + targetName + "' || label contains[c] '" + targetName + "'");
};
UIAElement.prototype.getPageSource = function () {

@@ -217,0 +288,0 @@ return JSON.stringify(this.getTree());

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc