appium-uiauto
Advanced tools
Comparing version 0.0.14 to 0.0.15
{ | ||
"name": "appium-uiauto", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "appium uiauto ios driver", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -551,2 +551,70 @@ /* globals codes, $ */ | ||
, _getElementByIndexPath: function (path, ctx) { | ||
if (typeof ctx === "undefined") { | ||
ctx = this.mainApp(); | ||
} | ||
var pathRegex = new RegExp("^/[0-9]+(/[0-9]+)*$"); | ||
if (!pathRegex.test(path)) { | ||
throw new Error("Path " + path + " was not a valid index path"); | ||
} | ||
// Throw away the empty path and the initial /X since that refers to ctx | ||
var pathSet = path.split("/").slice(2); | ||
var foundElement = ctx; | ||
for (var i = 0; i < pathSet.length; i++) { | ||
foundElement = foundElement.elements()[pathSet[i]]; | ||
if (foundElement.isNil()) { | ||
throw new Error("Could not find element with path " + path); | ||
} | ||
} | ||
return foundElement; | ||
} | ||
, _handleIndexPathError: function (err, many) { | ||
if (err.message.indexOf("Could not find") !== -1) { | ||
return { | ||
status: many ? | ||
codes.StaleElementReference.code : | ||
codes.NoSuchElement.code, | ||
value: err.message | ||
}; | ||
} else { | ||
return { | ||
status: codes.UnknownError.code, | ||
value: err.message | ||
}; | ||
} | ||
} | ||
, getElementByIndexPath: function (path, ctx) { | ||
this.target().pushTimeout(0); | ||
var ret; | ||
try { | ||
var elem = this._getElementByIndexPath(path, ctx); | ||
ret = this._returnFirstElem($([elem])); | ||
} catch (err) { | ||
ret = this._handleIndexPathError(err, false); | ||
} | ||
this.target().popTimeout(); | ||
return ret; | ||
} | ||
, getElementsByIndexPaths: function (paths, ctx) { | ||
var elems = []; | ||
var ret = null; | ||
this.target().pushTimeout(0); | ||
for (var i = 0; i < paths.length; i++) { | ||
try { | ||
elems.push(this._getElementByIndexPath(paths[i], ctx)); | ||
} catch (err) { | ||
ret = this._handleIndexPathError(err, true); | ||
break; | ||
} | ||
} | ||
if (ret === null) { | ||
ret = this._returnElems($(elems)); | ||
} | ||
this.target().popTimeout(); | ||
return ret; | ||
} | ||
, getActiveElement: function () { | ||
@@ -553,0 +621,0 @@ return $(this.mainWindow()).getActiveElement(); |
@@ -145,2 +145,42 @@ /* globals $, au, codes */ | ||
UIAElement.prototype.getTreeForXML = function () { | ||
var target = UIATarget.localTarget(); | ||
target.pushTimeout(0); | ||
var getTree = function (element, elementIndex, parentPath) { | ||
var curPath = parentPath + "/" + elementIndex; | ||
var rect = element.rect(); | ||
var subtree = { | ||
"@": { | ||
name: element.name() | ||
, label: element.label() | ||
, value: element.value() | ||
, dom: typeof element.dom === "function" ? element.dom() : null | ||
, enabled: element.isEnabled() ? true : false | ||
, valid: element.isValid() ? true : false | ||
, visible: element.isVisible() === 1 ? true : false | ||
, hint: element.hint() | ||
, path: curPath | ||
, x: rect.origin.x | ||
, y: rect.origin.y | ||
, width: rect.size.width | ||
, height: rect.size.height | ||
} | ||
, ">": [] | ||
}; | ||
var children = element.elements(); | ||
var numChildren = children.length; | ||
for (var i = 0; i < numChildren; i++) { | ||
var child = children[i]; | ||
subtree[">"].push(getTree(child, i, curPath)); | ||
} | ||
var elType = element.type(); | ||
var obj = {}; | ||
obj[elType] = subtree; | ||
return obj; | ||
}; | ||
var tree = getTree(this, 0, ""); | ||
target.popTimeout(); | ||
return JSON.stringify(tree); | ||
}; | ||
UIAElement.prototype.getTree = function () { | ||
@@ -176,3 +216,2 @@ var target = UIATarget.localTarget(); | ||
UIAElement.prototype.getPageSource = function () { | ||
@@ -179,0 +218,0 @@ return JSON.stringify(this.getTree()); |
@@ -27,3 +27,3 @@ /* globals system, nodePath, fileExists */ | ||
var args = [clientPath, '-s', '/tmp/instruments_sock'], res; | ||
if (typeof result !== "undefined") { | ||
@@ -33,4 +33,5 @@ args = args.concat(['-r', JSON.stringify(result)]); | ||
var cmd = nodePath + " " + args.join(" "); | ||
var cmdLog = cmd.slice(0, 300); | ||
try { | ||
console.log("Running command #" + curAppiumCmdId + ": " + cmd); | ||
console.log("Running command #" + curAppiumCmdId + ": " + cmdLog); | ||
res = system.performTaskWithPathArgumentsTimeout(nodePath, args, waitForDataTimeout); | ||
@@ -37,0 +38,0 @@ } catch (e) { |
Sorry, the diff of this file is not supported yet
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
313930
26
2465
6