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.15 to 0.0.16

.package.json.un~

2

package.json
{
"name": "appium-uiauto",
"version": "0.0.15",
"version": "0.0.16",
"description": "appium uiauto ios driver",

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

@@ -328,2 +328,5 @@ /* globals codes, $ */

if (typeof this.cache[name] !== 'undefined') {
if (this.cache[name].isNil()) {
throw new Error(codes.StaleElementReference.code);
}
return this.cache[name];

@@ -901,10 +904,23 @@ }

, hideKeyboard: function (keyName) {
try {
var keys = this.keyboard().buttons();
keys[keyName].tap();
} catch (e) {
if (keyName) {
console.log("Hiding keyboard with keyName " + keyName);
try {
var keys = this.keyboard().buttons();
keys[keyName].tap();
} catch (e) {
return {
status: codes.NoSuchElement.code
, value: "Could not find the '" + keyName + "' button, " +
"you're on your own for closing it!"
};
}
} else if (!au.mainApp().keyboard().isNil()) {
console.log("Hiding keyboard using default method");
var startY = au.mainApp().keyboard().rect().origin.y - 10;
var endY = au.mainWindow().rect().size.height - 10;
au.flickApp(0, startY, 0, endY);
} else {
return {
status: codes.NoSuchElement.code
, value: "Could not find the '" + keyName + "' button, " +
"you're on your own for closing it!"
, value: "The keyboard was not present, not closing it"
};

@@ -911,0 +927,0 @@ }

@@ -47,3 +47,14 @@ /* globals target, curAppiumCmdId, getFirstCommand, sendResultAndGetNext, codes */

/* jshint evil:true */
result = eval(cmd);
try {
result = eval(cmd);
} catch (possStaleEl) {
if (possStaleEl.message === codes.StaleElementReference.code) {
result = {
status: codes.StaleElementReference.code,
value: codes.StaleElementReference.summary
};
} else {
throw possStaleEl;
}
}
}

@@ -50,0 +61,0 @@ } catch (e) {

/* globals sysExec, dirExists, fileExists */
/* exported WAIT_FOR_DATA_TIMEOUT, system, target, mainWindow, mainWindow, wd_frame */

@@ -10,134 +11,168 @@ // automation globals

/* local env */
/* exported system, target, mainWindow, mainWindow, wd_frame */
// local environment
var user = null,
settings = {},
isVerbose = true,
nodePath;
isVerbose = false,
nodePath,
instrumentsClientPath,
WAIT_FOR_DATA_TIMEOUT = 3600;
// retrieving user
(function () {
var getUserFromCommand = function (cmd) {
var _user;
try {
_user = sysExec(cmd);
} catch (ign) {}
if (_user && dirExists('/Users/' + _user)) {
console.log("Found user using cmd: " + cmd + ', user:' + _user);
return _user;
} else return null;
};
console.start('Bootstrapping uiauto');
var earlyLogs = []; // cannot properly log before isVerbose has been read from settings
var cmds = [
'whoami',
'echo $HOME | cut -d / -f3',
'ls -d ~ | cut -d / -f3'
];
for (var i = 0; i < cmds.length; i++) {
user = getUserFromCommand(cmds[i]);
if (user) break;
}
if (!user) console.error("Could not get user");
})();
// retrieving user
(function () {
var getUserFromCommand = function (cmd) {
var _user;
try {
_user = sysExec(cmd);
} catch (ign) {}
if (_user && dirExists('/Users/' + _user)) {
earlyLogs.push("Found user using cmd: " + cmd + ', user:' + _user);
return _user;
} else return null;
};
var cmds = [
'whoami',
'echo $HOME | cut -d / -f3',
'ls -d ~ | cut -d / -f3'
];
for (var i = 0; i < cmds.length; i++) {
user = getUserFromCommand(cmds[i]);
if (user) break;
}
console.start(user ? "Got user: " + user : "Could not get user");
})();
// retrieving settings + isVerbose
(function () {
var settingsFile = "/Users/" + user + "/.instruments.conf";
if (fileExists(settingsFile)) {
console.log('Using setting file:' + settingsFile);
var lines = sysExec("/bin/cat " + settingsFile).split('\n');
for (var index = 0; index < lines.length; index++) {
var line = lines[index];
if (line[0] === '#') continue;
if (line.indexOf('=') !== -1) {
var parts = line.split('=');
if (parts.length !== 2) {
throw new Error("Error reading " + settingsFile);
// retrieving settings + isVerbose
(function () {
var settingsFile = "/Users/" + user + "/.instruments.conf";
if (fileExists(settingsFile)) {
console.start('Using setting file: ' + settingsFile);
var lines = sysExec("/bin/cat " + settingsFile).split('\n');
for (var index = 0; index < lines.length; index++) {
var line = lines[index];
if (line[0] === '#') continue;
if (line.indexOf('=') !== -1) {
var parts = line.split('=');
if (parts.length !== 2) {
throw new Error("Error reading " + settingsFile);
}
settings[parts[0]] = parts[1];
}
settings[parts[0]] = parts[1];
}
}
isVerbose = settings.verbose === 'true';
if (settings.length > 0) {
console.log("Read in settings: ");
}
for (var key in settings) {
if (settings.hasOwnProperty(key)) {
console.log(" " + key + ": " + settings[key]);
isVerbose = settings.verbose === 'true';
console.start("isVerbose:" + isVerbose);
// now it's time to print early logs
for (var i = 0; i < earlyLogs.length; i++) {
console.log(earlyLogs[i]);
}
if (settings.length > 0) {
console.log("Read in settings: ");
for (var key in settings) {
if (settings.hasOwnProperty(key)) {
console.log(" " + key + ": " + settings[key]);
}
}
}
} else {
console.start('Not using settings file.');
console.start("isVerbose:" + isVerbose);
isVerbose = false;
}
} else {
console.log('Not using settings file.');
isVerbose = false;
}
})();
})();
// retrieving node path
(function () {
var getNodePathFromCommand = function (cmd) {
var path;
try {
path = sysExec(cmd);
} catch (ign) {}
if (path && fileExists(path)) {
console.log("Found node using cmd: " + cmd + ', path:' + path);
return path;
} else return null;
};
// retrieving node path
(function () {
var getNodePathFromCommand = function (cmd) {
var path;
try {
path = sysExec(cmd);
} catch (ign) {}
if (path && fileExists(path)) {
console.log("Found node using cmd: " + cmd + ', path:' + path);
return path;
} else return null;
};
var getNodePathFromSettings = function () {
var path;
if ((typeof settings !== "undefined") && ('NODE_BIN' in settings)) {
path = settings.NODE_BIN;
var getNodePathFromSettings = function () {
var path;
if ((typeof settings !== "undefined") && ('NODE_BIN' in settings)) {
path = settings.NODE_BIN;
}
if (path && fileExists(path)) {
console.log("Using settings override for NODE_BIN: " + settings.NODE_BIN);
return path;
} else return null;
};
var getNodePathFromAppiumApp = function () {
var appScript = [
'try',
' set appiumIsRunning to false',
' tell application "System Events"',
' set appiumIsRunning to name of every process contains "Appium"',
' end tell',
' if appiumIsRunning then',
' tell application "Appium" to return node path',
' end if',
'end try',
'return "NULL"'
].join("\n");
var path = null;
try {
path = sysExec("osascript -e '" + appScript + "'");
} catch (ign) {}
if (path === "NULL") path = null;
if (path && fileExists(path)) {
console.log("Found node in Appium.app. path: " + path);
return path;
} else return null;
};
nodePath = getNodePathFromSettings();
if (!nodePath) nodePath = getNodePathFromCommand('/usr/bin/env node -e "console.log(process.execPath);"');
if (!nodePath) nodePath = getNodePathFromAppiumApp();
if (!nodePath) {
var cmds = [
'echo $NODE_BIN',
'which node',
'ls /usr/local/bin/node',
'ls /opt/local/bin/node'
];
for (var i = 0; i < cmds.length; i++) {
nodePath = getNodePathFromCommand(cmds[i]);
if (nodePath) break;
}
}
if (path && fileExists(path)) {
console.log("Using settings override for NODE_BIN: " + settings.NODE_BIN);
return path;
} else return null;
};
if (!nodePath) {
throw new Error("Could not find node, where is it?");
}
console.start("Using node at: " + nodePath);
})();
var getNodePathFromAppiumApp = function () {
var appScript = [
'try',
' set appiumIsRunning to false',
' tell application "System Events"',
' set appiumIsRunning to name of every process contains "Appium"',
' end tell',
' if appiumIsRunning then',
' tell application "Appium" to return node path',
' end if',
'end try',
'return "NULL"'
].join("\n");
var path = null;
try {
path = sysExec("osascript -e '" + appScript + "'");
} catch (ign) {}
if (path === "NULL") path = null;
if (path && fileExists(path)) {
console.log("Found node in Appium.app. path: " + path);
return path;
} else return null;
};
nodePath = getNodePathFromSettings();
if (!nodePath) nodePath = getNodePathFromCommand('/usr/bin/env node -e "console.log(process.execPath);"');
if (!nodePath) nodePath = getNodePathFromAppiumApp();
if (!nodePath) {
var cmds = [
'echo $NODE_BIN',
'which node',
'ls /usr/local/bin/node',
'ls /opt/local/bin/node'
];
for (var i = 0; i < cmds.length; i++) {
nodePath = getNodePathFromCommand(cmds[i]);
if (nodePath) break;
// figure out where instruments client is (relative to where appium is run)
(function () {
var getClientPath = function () {
var possiblePaths = [
'./node_modules/.bin/instruments-client.js',
'./node_modules/appium/node_modules/.bin/instruments-client.js'
];
for (var i = 0; i < possiblePaths.length; i++) {
if (fileExists(possiblePaths[i])) {
return possiblePaths[i];
}
}
};
instrumentsClientPath = getClientPath();
if (!instrumentsClientPath) {
throw new Error("Could not find instruments clientPath, where is it?");
}
}
if (!nodePath) {
throw new Error("Could not find node, Where is it?");
}
console.log('Using instrument client at: ' + instrumentsClientPath);
})();
})();

@@ -9,4 +9,10 @@ /* globals isVerbose, system, user */

},
warn: function (msg) {
UIALogger.logWarning("Warn: " + msg);
},
start: function (msg) {
UIALogger.logStart(msg);
},
error: function (msg) {
UIALogger.logMessage("Error: " + msg);
UIALogger.logError("Error: " + msg);
}

@@ -13,0 +19,0 @@ };

@@ -1,2 +0,4 @@

/* globals system, nodePath, fileExists */
/* globals system, nodePath , instrumentsClientPath,
WAIT_FOR_DATA_TIMEOUT
*/

@@ -8,21 +10,5 @@ var sendResultAndGetNext,

(function () {
var waitForDataTimeout = 3600;
// figure out where instruments client is (relative to where appium is run)
var getClientPath = function () {
var possiblePaths = [
'./node_modules/.bin/instruments-client.js',
'./node_modules/appium/node_modules/.bin/instruments-client.js'
];
for (var i = 0; i < possiblePaths.length; i++) {
if (fileExists(possiblePaths[i])) {
return possiblePaths[i];
}
}
};
var clientPath = getClientPath();
console.log('Using instrument client with path: ' + clientPath);
sendResultAndGetNext = function (result) {
curAppiumCmdId++;
var args = [clientPath, '-s', '/tmp/instruments_sock'], res;
var args = [instrumentsClientPath, '-s', '/tmp/instruments_sock'], res;

@@ -36,3 +22,3 @@ if (typeof result !== "undefined") {

console.log("Running command #" + curAppiumCmdId + ": " + cmdLog);
res = system.performTaskWithPathArgumentsTimeout(nodePath, args, waitForDataTimeout);
res = system.performTaskWithPathArgumentsTimeout(nodePath, args, WAIT_FOR_DATA_TIMEOUT);
} catch (e) {

@@ -39,0 +25,0 @@ console.log(e.name + " error getting command " + curAppiumCmdId + ": " + e.message);

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