npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bat-driver

v6.7.5

Published

Bat Driver 是智能小程序自动化测试引擎 betterAutoTest 的 client lib 库,提供了一系列的 API 用于操控智能小程序。

Readme

Bat Driver

Bat Driver 是智能小程序自动化测试引擎 betterAutoTest 的 client lib 库,提供了一系列的 API 用于操控智能小程序。

快速开始

Node.js

const BatDriver = require('bat-driver');
const fs = require('fs');

const agentInfo = {host: 'localhost', port: 8090};
const smartappKey = 'ccccccKCYawUcfCxivhfmhhhCICGK0IX'; // 被测小程序的 appkey

let driver;
let res;

const main = async () => {
    try {
        // 初始化 driver
        driver = new BatDriver();
        await driver.init(agentInfo);

        // 获取当前在连的空闲设备
        res = await driver.device.idle({type: 'android'}); 
        if (0 === res.length) {
            console.log('无设备连接');
            process.exit();
        }

        // 设定被测设备
        driver.device.set({type: 'android', id: res[0]});

        // 设定被测小程序
        driver.smartapp.set({host: 'baiduboxapp', type: 'swan', id: smartappKey});

        // 打开小程序
        await driver.smartapp.open();

        // 获取页面的 dom 树
        await driver.smartapp.source()

        // 关闭 driver
        driver.close();
    }
    catch (err) {
        console.log('调用异常', err.message);
    }
}

main();

API 列表

设备管理

device.idle 获取空闲设备列表
参数说明

|参数名|类型|是否必填|默认值|说明| |-|-|-|-|-| |type|string|是|-|设备类型:android | ios|

调用示例
await driver.device.idle({type: 'android'});
返回示例
['123b9db9']
device.list 获取设备列表
参数说明

|参数名|类型|是否必填|默认值|说明| |-|-|-|-|-| |type|string|是|-|设备类型:android | ios|

调用示例
await driver.device.list({type: 'android'});
返回示例
['123b9db9']
device.get 获取指定设备信息
参数说明:无参数
调用示例
await driver.device.get();
返回示例
{smartapps: {}}
device.set 指定设备
参数说明

|参数名|类型|是否必填|默认值|说明| |-|-|-|-|-| |type|string|是|-|设备类型:android | ios| |id|number|是|-|设备id|

调用示例
await driver.device.set({type: 'android', id: '123b9db9'});
返回示例:无返回值

小程序操作

smartapp.set 指定小程序
参数说明

|参数名|类型|是否必填|默认值|说明| |-|-|-|-|-| |host|string|是|-|baiduboxapp| |type|string|是|-|小程序传 swan,小游戏传 swangame| |id|number|是|-|小程序 appkey|

调用示例
await driver.smartapp.set();
返回示例:无返回
smartapp.open 打开小程序
参数说明:无参数
调用示例
await driver.smartapp.open();
返回示例
true

测试

npm run test

如何贡献

联系我们

维护者

邱立楷

讨论

百度Hi讨论群:2148505