Gathering detailed insights and metrics for @devicefarmer/adbkit-monkey
Gathering detailed insights and metrics for @devicefarmer/adbkit-monkey
Gathering detailed insights and metrics for @devicefarmer/adbkit-monkey
Gathering detailed insights and metrics for @devicefarmer/adbkit-monkey
A Node.js interface to the Android monkey tool.
npm install @devicefarmer/adbkit-monkey
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99
Supply Chain
99.5
Quality
80.4
Maintenance
100
Vulnerability
100
License
CoffeeScript (97.17%)
Shell (2.83%)
Total Downloads
5,549,528
Last Day
1,995
Last Week
53,467
Last Month
262,252
Last Year
2,328,452
9 Stars
117 Commits
9 Forks
2 Watching
12 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.2.1
Package Id
@devicefarmer/adbkit-monkey@1.2.1
Unpacked Size
33.26 kB
Size
7.80 kB
File Count
15
NPM Version
6.14.16
Node Version
12.22.12
Cumulative downloads
Total Downloads
Last day
-21.9%
1,995
Compared to previous day
Last week
-18.4%
53,467
Compared to previous week
Last month
-16.8%
262,252
Compared to previous month
Last year
80.5%
2,328,452
Compared to previous year
adbkit-monkey provides a Node.js interface for working with the Android monkey
tool. Albeit undocumented, they monkey program can be started in TCP mode with the --port
argument. In this mode, it accepts a range of commands that can be used to interact with the UI in a non-random manner. This mode is also used internally by the monkeyrunner
tool, although the documentation claims no relation to the monkey tool.
Install via NPM:
1npm install --save adbkit-monkey
Note that while adbkit-monkey is written in CoffeeScript, it is compiled to JavaScript before publishing to NPM, which means that you are not required to use CoffeeScript.
The following examples assume that monkey is already running (via adb shell monkey --port 1080
) and a port forwarding (adb forward tcp:1080 tcp:1080
) has been set up.
1var assert = require('assert'); 2var monkey = require('adbkit-monkey'); 3 4var client = monkey.connect({ port: 1080 }); 5 6client.press(3 /* KEYCODE_HOME */, function(err) { 7 assert.ifError(err); 8 console.log('Pressed home button'); 9 client.end(); 10});
1var assert = require('assert'); 2var monkey = require('adbkit-monkey'); 3 4var client = monkey.connect({ port: 1080 }); 5 6client.multi() 7 .touchDown(100, 0) 8 .sleep(5) 9 .touchMove(100, 20) 10 .sleep(5) 11 .touchMove(100, 40) 12 .sleep(5) 13 .touchMove(100, 60) 14 .sleep(5) 15 .touchMove(100, 80) 16 .sleep(5) 17 .touchMove(100, 100) 18 .sleep(5) 19 .touchUp(100, 100) 20 .sleep(5) 21 .execute(function(err) { 22 assert.ifError(err); 23 console.log('Dragged out the notification bar'); 24 client.end(); 25 });
1var assert = require('assert'); 2var monkey = require('adbkit-monkey'); 3 4var client = monkey.connect({ port: 1080 }); 5 6client.getDisplayWidth(function(err, width) { 7 assert.ifError(err); 8 client.getDisplayHeight(function(err, height) { 9 assert.ifError(err); 10 console.log('Display size is %dx%d', width, height); 11 client.end(); 12 }); 13});
Note that you should manually focus a text field first.
1var assert = require('assert'); 2var monkey = require('adbkit-monkey'); 3 4var client = monkey.connect({ port: 1080 }); 5 6client.type('hello monkey!', function(err) { 7 assert.ifError(err); 8 console.log('Said hello to monkey'); 9 client.end(); 10});
Uses Net.connect() to open a new TCP connection to monkey. Useful when combined with adb forward
.
Net.connect()
accepts.Client
instance.Attaches a monkey client to an existing monkey protocol stream.
Stream
.Client
instance.Implements Api
. See below for details.
The following events are available:
Error
.Ends the underlying stream/connection.
Client
instance.Returns a new API wrapper that buffers commands for simultaneous delivery instead of sending them individually. When used with api.sleep()
, allows simple gestures to be executed.
Multi
instance. See Multi
below.Sends a raw protocol command to monkey.
String
, a single command is sent. When Array
, a series of commands is sent at once.null
when successful, Error
otherwise.Client
instance.The monkey API implemented by Client
and Multi
.
Closes the current monkey session and allows a new session to connect.
null
when successful, Error
otherwise.Api
implementation instance.Simulates closing the keyboard.
null
when successful, Error
otherwise.Api
implementation instance.Simulates opening the keyboard.
null
when successful, Error
otherwise.Api
implementation instance.Gets the value of a variable. Use api.list()
to retrieve a list of supported variables.
null
when successful, Error
otherwise.Api
implementation instance.Alias for api.get('am.current.action', callback)
.
Alias for api.get('am.current.categories', callback)
.
Alias for api.get('am.current.comp.class', callback)
.
Alias for api.get('am.current.comp.package', callback)
.
Alias for api.get('am.current.data', callback)
.
Alias for api.get('am.current.package', callback)
.
Alias for api.get('build.board', callback)
.
Alias for api.get('build.brand', callback)
.
Alias for api.get('build.cpu_abi', callback)
.
Alias for api.get('build.device', callback)
.
Alias for api.get('build.display', callback)
.
Alias for api.get('build.fingerprint', callback)
.
Alias for api.get('build.host', callback)
.
Alias for api.get('build.id', callback)
.
Alias for api.get('build.manufacturer', callback)
.
Alias for api.get('build.model', callback)
.
Alias for api.get('build.product', callback)
.
Alias for api.get('build.tags', callback)
.
Alias for api.get('build.type', callback)
.
Alias for api.get('build.user', callback)
.
Alias for api.get('build.version.codename', callback)
.
Alias for api.get('build.version.incremental', callback)
.
Alias for api.get('build.version.release', callback)
.
Alias for api.get('build.version.sdk', callback)
.
Alias for api.get('clock.millis', callback)
.
Alias for api.get('clock.realtime', callback)
.
Alias for api.get('clock.uptime', callback)
.
Alias for api.get('display.density', callback)
.
Alias for api.get('display.height', callback)
. Note that the height may exclude any virtual home button row.
Alias for api.get('display.width', callback)
.
Sends a key down event. Should be coupled with api.keyUp()
. Note that api.press()
performs the two events automatically.
'home'
to KEYCODE_HOME
). This will not work for number keys however. The most portable method is to simply use numeric key codes.null
when successful, Error
otherwise.Api
implementation instance.Sends a key up event. Should be coupled with api.keyDown()
. Note that api.press()
performs the two events automatically.
api.keyDown()
.null
when successful, Error
otherwise.Api
implementation instance.Lists supported variables.
null
when successful, Error
otherwise.api.get()
.Api
implementation instance.Sends a key press event.
api.keyDown()
.null
when successful, Error
otherwise.Api
implementation instance.Closes the current monkey session and quits monkey.
null
when successful, Error
otherwise.Api
implementation instance.Sleeps for the given duration. Can be useful for simulating gestures.
null
when successful, Error
otherwise.Api
implementation instance.Taps the given coordinates.
null
when successful, Error
otherwise.Api
implementation instance.Sends a touch down event on the given coordinates.
null
when successful, Error
otherwise.Api
implementation instance.Sends a touch move event on the given coordinates.
null
when successful, Error
otherwise.Api
implementation instance.Sends a touch up event on the given coordinates.
null
when successful, Error
otherwise.Api
implementation instance.Sends a trackball event on the given coordinates.
null
when successful, Error
otherwise.Api
implementation instance.Types the given text.
String
. Note that only characters for which key codes exist can be entered. Also note that any IME in use may or may not transform the text.null
when successful, Error
otherwise.Api
implementation instance.Wakes the device from sleep and allows user input.
null
when successful, Error
otherwise.Api
implementation instance.Buffers Api
commands and delivers them simultaneously for greater control over timing.
Implements all Api
methods, but without the last callback
parameter.
Sends all buffered commands.
null
when successful, Error
otherwise.Api
responses.See CONTRIBUTING.md.
See LICENSE.
Copyright © CyberAgent, Inc. All Rights Reserved.
No vulnerabilities found.
No security vulnerabilities found.