bat-api
v1.1.55
Published
## Installation
Downloads
18
Readme
Bat-Driver Api
Installation
$ npm i bat-api
Documentation
Usage
const batDriver = require('bat-api');
const remoteConfig = {
host: 'localhost',
port: 8090
}
const main = async () => {
// create driver handler
let driver = new batDriver(remoteConfig);
// bind linstener
driver.bind('device.del', sn => {
console.log(sn);
});
// call driver by the protocol
let res = await driver.call('container.idle', {
type: 'android'
});
// init driver, specify the device info
driver.initDevice({type: 'android', id: 'PBV0216620000092'});
// call driver by the adb method
res = await driver.adb.devices();
// close driver
driver.close();
}
main();
API
基础 API
bind
绑定监听事件,监听 Bat-driver 的事件推送
Parameters
|Name|Type|Description| |-|-|-| |method|string|监听事件| |callback|Function|处理函数|
close
关闭 Bat-driver 代理
call → { Promise.< Object > }
向 Bat-driver 发起远程方法调用。
通信协议详情请见:./docs/protocol.md
Parameters
|Name|Type|Description| |-|-|-| |method|string|调用方法| |payload|Function|携带参数| |timeout|int|调用超时时间|
Returns
Type Promise.< Object >