# Quick Getting Started
# Operating environment
- Install
Node.jsand version greater than 8.0 - Base library version
2.7.3and above - The developer tool version is
1.02.1907232and above
# install
Use the Weixin Mini Program SDK to directly execute the following command:
npm i miniprogram-automator --save-dev
# use
First turn on 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 launch the tool automation function properly.
Then directly into the SDK to start writing control scripts, refer to the following example:
const automator = require('miniprogram-automator')
automator.launch({
cliPath: 'path/to/cli', // 工具 cli 位置,如果你没有更改过默认安装位置,可以忽略此项
projectPath: 'path/to/project', // 项目文件地址
}).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, executenode path / to / scriptto see the output.
For more detailed usage of the interface provided by the SDK, see Automator 、 MiniProgram 、 Page 、 Element 。