Quick Start

View Markdown

Last edited on 2026-08-21

Runtime Environment

  • Install Node.js with a version greater than 8.0
  • Base library version of 2.7.3 or higher
  • Developer Tools version of 1.02.1907232 or higher

Installation

Using the Mini Program automation SDK, execute the following command directly:

npm i miniprogram-automator --save-dev

Usage

First, enable the CLI/HTTP invocation feature in the tool's security settings.

The above options must be enabled; otherwise, the SDK will not be able to start the tool automation features normally.

Then, directly import the SDK to start writing control scripts. Refer to the example below:

const automator = require('miniprogram-automator')

automator.launch({
  cliPath: 'path/to/cli', // Location of the tool CLI. If you have not changed the default installation location, you can ignore this option.
  projectPath: 'path/to/project', // Project file path.
}).then(async miniProgram => {
  const page = await miniProgram.reLaunch('/page/component/index')
  await page.waitFor(500)
  const element = await page.$('.kind-list-item-hd')
  console.log(await element.attribute('class'))
  await element.tap()

  await miniProgram.close()
})

Finally, run node path/to/script to see the output results.

For more detailed usage of the interfaces provided by the SDK, refer to Automator, MiniProgram, Page, and Element.