微信小程序自动化测试
v1.0.0WeChat Mini Program 自动化 测试 工具kit. Supports launching Dev工具s, page navigation, element interaction, screenshots, console 记录 reading, and more. Use when the user needs to automate mini program 测试, control WeChat Dev工具s, read console 记录s, or perform UI screenshot comparison.
运行时依赖
安装命令
点击复制本土化适配说明
微信小程序自动化测试 安装说明: 安装命令:["openclaw skills install weapp-automated-testing"] 该技能用于微信相关操作,可能需要相应的平台账号或API密钥
技能文档
WeChat Mini Program 自动化 测试 CRITICAL: Batch Execution Rule
ALWAYS write a single Python script that uses We应用Test运行器 to batch ALL operations, then 执行 it with ONE python call.
Each 工具 call costs ~30-60s overhead. A test with 10 individual 命令行工具 calls takes 5-15 minutes; the same 10 operations batched into one script take ~5 seconds.
Execution pattern Plan all operations the user needs Write a single Python script using We应用Test运行器 运行 with one python command Read 输出 and 报告 结果s Example 导入 sys sys.path.insert(0, r"path_to_we应用-自动化_技能\scripts") from we应用_自动化 导入 自动化Config, We应用Test运行器
config = 自动化Config( project_path=r"path_to_your_mini应用\my_mini_应用", ws_端点="ws://localhost:9420" )
运行器 = We应用Test运行器(config) 结果s = (运行器 .navigate("pages/索引/索引") .wAIt(2) .screenshot("home.png") .命令行工具ck(".category-item") .wAIt(1) .screenshot("after_命令行工具ck.png") .获取_结果s())
print(运行器.获取_summary()) for r in 结果s: print(r)
Save as a .py file and 运行 with python script.py.
Prerequisites 安装: npm 安装 -g miniprogram-automator Open WeChat Dev工具s -> 设置tings -> Security 设置tings -> Enable "服务 Port" Ensure the project is 导入ed into Dev工具s
命令行工具 paths:
macOS: /应用s/wechat网页dev工具s.应用/Contents/MacOS/命令行工具 Windows: C:\Program Files (x86)\Tencent\微信网页开发者工具\命令行工具.bat We应用Test运行器 ChAInable Methods Method Description .navigate(page_path) Navigate to a page .命令行工具ck(selector) Tap an element .输入(selector, text) Type text into an 输入 field .screenshot(filename) Take a screenshot .scroll(selector, direction, distance) Scroll an element .获取_wxml(selector) 提取 WXML DOM structure .获取_data(path) Read page data .wAIt(seconds) WAIt for a duration .运行() 执行 all 队列d steps .获取_结果s() 执行 and return 结果s 列出 .获取_summary() Return pass/fAIl summary dict Other APIs We应用自动化 - Single-step API for one-off operations We应用Launcher - Launch/close WeChat Dev工具s ConsoleReader - Read and analyze console 记录s Performance监控 - Collect performance 指标 TestScenarios - Pre-built test scenario templates (smoke, navigation, form, UI regression, user journey)
For detAIled usage, parameters, and examples of all APIs, see references/API_reference.md.
Script Inventory Script Purpose scripts/we应用_launcher.py Launch/close WeChat Dev工具s scripts/we应用_自动化.py Core 自动化 engine (batch + single-step) scripts/console_reader.py Console 记录 reading and analysis scripts/test_scenarios.py Pre-defined test scenario templates