[Automation Testing] Use miniprogram-automator and Wechat Devtools to test Miniprogram automatically
miniprogram-automator
miniprogram-automator is the Miniprogram Automation SDK provides developers with a set of solutions for manipulating Miniprograms through external scripts and Wechat Devtools so as to achieve the purpose of Miniprogram automation testing.
Prerequisites
-
Node.js
Install Node.js - https://nodejs.org/en/ 8.0+.
-
Mini Program account
The first step in developing the Mini Program is to have a Mini Program account that allows you to manage your Mini Program
Log in WeChat Official Accounts Platform - https://mp.weixin.qq.com, and you can see the AppID of your Mini Program in the menu of “Settings” - “Development Settings”.
-
Wechat Devtools
Go to the developer toolkit download page to download the appropriate installation package for your operating system. More details about the developer toolkit can be found in the Developer Toolkit Introduction.
1
2
3
4Install by Homebrew package manager on macOS.
wechatwebdevtools — Homebrew Formulae
https://formulae.brew.sh/cask/wechatwebdevtools
brew install --cask wechatwebdevtoolsOpen the Wechat Devtools, and log in by scanning QR code with your Weixin. Now you are ready to develop your first Mini Program!
Installation
First, install miniprogram-automator SDK.
1 | (Optional) Make a workspace folder and initialize npm package.json. |
Configuration
Enable the CLI/HTTP call function in the Wechat Devtools security settings in Settings -> Security Settings.
The above options must be enabled, otherwise the SDK will not be able to start the tool automation function normally.
Examples
1 | // index.js |
Run
Run index.js
with node
command.
1 | node index.js |
Or run index.js
with npm
run script.
First, edit and append the follow content in the package.json
file.
1 | cat package.json |
Then, run with npm script.
1 | npm run test |
You will Wechat Devtools run your Miniprogram project automatically and generate the screenshots.
References
[1] 快速入门 | 微信开放文档 - https://developers.weixin.qq.com/miniprogram/dev/devtools/auto/quick-start.html
[3] Node.js - https://nodejs.org/en/
[4] wechatwebdevtools — Homebrew Formulae - https://formulae.brew.sh/cask/wechatwebdevtools