ALWAYS write a single Python script that uses WeappTestRunner to batch ALL operations, then execute it with ONE python call.
Each tool call costs ~30-60s overhead. A test with 10 individual CLI calls takes 5-15 minutes; the same 10 operations batched into one script take ~5 seconds.
WeappTestRunnerpython commandpython
import sys
sys.path.insert(0, r"path_to_weapp-automation_skill\scripts")
from weapp_automation import AutomationConfig, WeappTestRunner
config = AutomationConfig(
project_path=r"path_to_your_miniapp\my_mini_app",
ws_endpoint="ws://localhost:9420"
)
runner = WeappTestRunner(config)
results = (runner
.navigate("pages/index/index")
.wait(2)
.screenshot("home.png")
.click(".category-item")
.wait(1)
.screenshot("after_click.png")
.get_results())
print(runner.get_summary())
for r in results:
print(r)
Save as a .py file and run with python script.py.
npm install -g miniprogram-automatorCLI paths:
/Applications/wechatwebdevtools.app/Contents/MacOS/cliC:\Program Files (x86)\Tencent\微信web开发者工具\cli.batMethodDescription.navigate(page_path)Navigate to a page.click(selector)Tap an element.input(selector, text)Type text into an input field.screenshot(filename)Take a screenshot.scroll(selector, direction, distance)Scroll an element.get_wxml(selector)Extract WXML DOM structure.get_data(path)Read page data.wait(seconds)Wait for a duration.run()Execute all queued steps.get_results()Execute and return results list.get_summary()Return pass/fail summary dict
For detailed usage, parameters, and examples of all APIs, see references/api_reference.md.
ScriptPurposescripts/weapp_launcher.pyLaunch/close WeChat DevToolsscripts/weapp_automation.pyCore automation engine (batch + single-step)scripts/console_reader.pyConsole log reading and analysisscripts/test_scenarios.pyPre-defined test scenario templates