New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

macaca-android

Package Overview
Dependencies
Maintainers
6
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

macaca-android - npm Package Compare versions

Comparing version 1.1.34 to 2.0.0

193

lib/controllers.js

@@ -40,3 +40,3 @@ 'use strict';

} else {
this.proxy = null;
this.proxy = this.uiautomator;
}

@@ -46,97 +46,2 @@ this.context = name;

controllers.click = function *(elementId) {
return yield this.send({
cmd: 'click',
args: {
elementId: elementId
}
});
};
controllers.getWindowSize = function *() {
var size = yield this.send({
cmd: 'getWindowSize',
args: {}
});
return JSON.parse(size);
};
controllers.setValue = function *(elementId, value) {
return yield this.send({
cmd: 'setText',
args: {
elementId: elementId,
text: value.join('')
}
});
};
controllers.keys = function *(value) {
value = value.join('');
var arrText = [];
for (var i = 0; i < value.length; i++) {
var key = value.charAt(i);
const keyEvent = keyMap[key];
if (keyEvent) {
if (arrText.length) {
yield this.setValue('', arrText);
arrText = [];
}
yield this.adb.input(`keyevent ${keyEvent}`);
} else {
arrText.push(key);
}
}
if (arrText.length) {
yield this.setValue('', arrText);
}
return null;
};
controllers.getText = function *(elementId) {
var args = {
elementId: elementId
};
return yield this.send({
cmd: 'getText',
args: args
});
};
controllers.clearText = function *(elementId) {
var args = {
elementId: elementId
};
return yield this.send({
cmd: 'clearText',
args: args
});
};
controllers.findElement = function *(strategy, selector) {
var args = {
strategy: strategy,
selector: selector,
multiple: false
};
return yield this.send({
cmd: 'find',
args: args
});
};
controllers.findElements = function *(strategy, selector) {
var args = {
strategy: strategy,
selector: selector,
multiple: true
};
return yield this.send({
cmd: 'find',
args: args
});
};
controllers.getScreenshot = function *() {

@@ -148,3 +53,3 @@ const swapFilePath = temp.path({

const tmpDir = yield this.getTempDir();
const tmpDir = '/data/local/tmp';
const remoteFile = `${tmpDir}/screenshot.png`;

@@ -180,78 +85,2 @@ const cmd = `/system/bin/rm ${remoteFile}; /system/bin/screencap -p ${remoteFile}`;

controllers.getProperty = function *(elementId, name) {
var res = yield this.send({
cmd: 'getProperties',
args: {
elementId: elementId
}
});
var properties = JSON.parse(res);
var property = properties[name];
return property == null ? null: property;
};
controllers.getRect = function *(elementId) {
return yield this.send({
cmd: 'getRect',
args: {
elementId: elementId
}
});
};
controllers.getSource = function *() {
yield this.send({
cmd: 'getSource',
args: {
}
});
const tmpDir = yield this.getTempDir();
var xml = yield this.adb.shell(`cat ${tmpDir}/macaca-dump.xml`);
return xml;
};
controllers.getTempDir = function *(){
return yield this.send({
cmd: 'getTmpDir',
args: {
}
});
};
controllers.isDisplayed = function *(elementId) {
return yield this.send({
cmd: 'isDisplayed',
args: {
elementId: elementId
}
});
};
controllers.handleActions = function *(actions) {
if (!actions) {
throw new errors.UnknownError(`Missing 'actions' in parameters.`);
}
if (this.isWebContext()) {
const futureActions = actions.map(action => {
const actionDelegate = this[action.type];
if (actionDelegate) {
return actionDelegate.bind(this, action);
} else {
return () => {
throw new errors.NotImplementedError(`Action ${action.type} is not implemented yet.`);
};
}
});
return yield _.serialTasks.apply(null, futureActions);
} else {
return yield this.send({
cmd: 'actions',
args: {
actions: actions
}
});
}
};
controllers.tap = function(action) {

@@ -266,20 +95,2 @@ return this

controllers.acceptAlert = function *() {
return yield this.send({
cmd: 'alert',
args: {
action: 'accept'
}
});
};
controllers.dismissAlert = function *() {
return yield this.send({
cmd: 'alert',
args: {
action: 'dismiss'
}
});
};
module.exports = controllers;

61

lib/macaca-android.js

@@ -9,4 +9,4 @@ 'use strict';

const DriverBase = require('driver-base');
const UIAutomatorWD = require('uiautomatorwd');
const UnicodeInput = require('android-unicode');
const UIAutomator = require('uiautomator-client');
const ChromeDriver = require('macaca-chromedriver');

@@ -21,2 +21,3 @@ const errors = require('webdriver-dfn-error-code').errors;

const reuseStatus = {};
reuseStatus.noReuse = 0;

@@ -55,5 +56,3 @@ reuseStatus.reuseEmu = 1;

yield this.unlock();
yield this.setIME();
yield this.launchApk();
yield this.wake();

@@ -85,3 +84,9 @@ if (this.isChrome) {

var basename = path.basename(context.url);
const whiteList = ['context', 'contexts', 'screenshot', 'actions'];
const whiteList = [
'context',
'contexts',
'screenshot',
'back',
'tap'
];
return !!~whiteList.indexOf(basename);

@@ -95,3 +100,2 @@ };

Android.prototype.waitActivityReady = function *() {

@@ -115,4 +119,2 @@

yield _.sleep(1000);
var isActivityReady = false;

@@ -130,13 +132,2 @@

Android.prototype.wake = function *() {
yield this.waitActivityReady();
yield this.send({
cmd: 'wake',
args: {}
});
yield _.sleep(3000);
};
Android.prototype.initAdb = function() {

@@ -155,3 +146,4 @@ this.adb = new ADB();

Android.prototype.initUiautomator = function *() {
this.uiautomator = new UIAutomator();
this.uiautomator = new UIAutomatorWD();
this.proxy = this.uiautomator;
yield this.uiautomator.init(this.adb);

@@ -271,3 +263,2 @@ };

Android.prototype.setIME = function *() {
const isInstalled = yield this.adb.isInstalled(UnicodeInput.package);

@@ -329,12 +320,8 @@

}
if (!this.proxy) {
this.proxy = this.chromedriver;
}
this.proxy = this.chromedriver;
var webviews = [];
if (this.isProxy()) {
const result = yield this.proxy.sendCommand('/wd/hub/session/temp/window_handles', 'GET', {});
webviews = _.parseWebDriverResult(result);
}
const result = yield this.proxy.sendCommand('/wd/hub/session/temp/window_handles', 'GET', {});
webviews = _.parseWebDriverResult(result);

@@ -362,24 +349,4 @@ return webviews;

Android.prototype.send = function *(data) {
var result;
try {
result = yield this.uiautomator.send(data);
} catch (err) {
logger.debug(`UnknownError from uiautomator ${err}`);
throw new errors.UnknownError();
}
var statusCode = result.status;
if (statusCode === 0) {
return result.value;
} else {
var errName = getErrorByCode(statusCode);
if (!errName) {
throw new errors.UnknownError();
}
throw new errors[errName](result.value);
}
};
_.extend(Android.prototype, controllers);
module.exports = Android;
{
"name": "macaca-android",
"version": "1.1.34",
"version": "2.0.0",
"description": "Macaca Android driver",

@@ -14,3 +14,3 @@ "keywords": [

"dependencies": {
"android-unicode": "1.0.11",
"android-unicode": "~1.1.0",
"driver-base": "~0.1.0",

@@ -22,4 +22,4 @@ "java-util": "~0.1.0",

"temp": "~0.8.3",
"uiautomator-client": "1.1.9",
"unlock-apk": "~0.1.11",
"uiautomatorwd": "~1.0.0",
"unlock-apk": "~1.0.3",
"webdriver-dfn-error-code": "~1.0.1",

@@ -26,0 +26,0 @@ "xlogger": "~1.0.0"

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