@taole/dd-playwright 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/mcp-server.mjs +1 -1
- package/package.json +1 -1
- package/src/server/web-server.mjs +48 -4
package/bin/mcp-server.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { resolveConfig } from "../src/config.mjs";
|
|
|
11
11
|
import { PlaywrightBrowserManager } from "../src/browser-manager.mjs";
|
|
12
12
|
import { pathToFileURL } from "node:url";
|
|
13
13
|
|
|
14
|
-
export const MCP_VERSION = "0.1.
|
|
14
|
+
export const MCP_VERSION = "0.1.10";
|
|
15
15
|
|
|
16
16
|
function textResult(payload) {
|
|
17
17
|
return {
|
package/package.json
CHANGED
|
@@ -383,13 +383,58 @@ const DASHBOARD_HTML = `<!DOCTYPE html>
|
|
|
383
383
|
<b>2. 本地开发服务联调(Dev Server 代理映射):</b><br>
|
|
384
384
|
• 本地服务启动后严禁改动系统 hosts,可通过单域名映射或项目规则目录全量注入:<br>
|
|
385
385
|
• <b>单条映射</b>:<code>browser_set_proxy_rule({ domain: "p9527-test.tuwan.com", port: 9527 })</code><br>
|
|
386
|
-
• <b>目录批量规则(推荐)</b>:若项目有 <code>.whistle-rules</code> 目录,直接调用 <code>browser_load_proxy_rules_dir({ rulesDir: "目录绝对路径" })</code> 全量激活代理与 Mock。<br
|
|
386
|
+
• <b>目录批量规则(推荐)</b>:若项目有 <code>.whistle-rules</code> 目录,直接调用 <code>browser_load_proxy_rules_dir({ rulesDir: "目录绝对路径" })</code> 全量激活代理与 Mock。<br>
|
|
387
|
+
• <b>常用 Whistle 规则参考(.whistle-rules 编写)</b>:<br>
|
|
388
|
+
1) 域名映射:<code>p9527-test.tuwan.com http://127.0.0.1:9527</code><br>
|
|
389
|
+
2) 接口 Mock:<code>yapi.tuwan.com/act resBody://D:/mock/data.json</code><br>
|
|
390
|
+
3) 静态替换:<code>act.tuwan.com/cdn/index.js D:/dist/index.js</code><br>
|
|
391
|
+
4) 请求头注入:<code>y.tuwan.com reqHeaders://{debug: '1'}</code><br>
|
|
392
|
+
👉 官方完整语法参考:<a href="https://wproxy.org/whistle/rules/" target="_blank" style="color: #38bdf8; text-decoration: underline;">https://wproxy.org/whistle/rules/</a><br><br>
|
|
387
393
|
<b>3. 页面交互规范:</b><br>
|
|
388
394
|
• 复杂或动态页面定位困难时,优先调用 <code>browser_get_dom</code> 获取可见元素清单,严禁盲猜选择器。<br>
|
|
389
395
|
• 表单填写使用 <code>browser_fill_text</code>,按键使用 <code>browser_press_key</code>。
|
|
390
396
|
</div>
|
|
391
397
|
</div>
|
|
392
|
-
|
|
398
|
+
|
|
399
|
+
<!-- AI Agent 使用 SOP 与典型范例 -->
|
|
400
|
+
<div class="doc-section" style="margin-top: 24px;">
|
|
401
|
+
<h3>AI Agent 典型调用流程范例 (SOP)</h3>
|
|
402
|
+
<p>以下为 Agent 处理点点日常联调、排查与测试的三大标准工作流:</p>
|
|
403
|
+
|
|
404
|
+
<div class="code-title"><span>流程 1:本地开发服务(Dev Server)联调</span></div>
|
|
405
|
+
<div class="code-block" style="color: #93c5fd; font-size: 12px; margin-bottom: 12px;">// 方式 A:单域名映射
|
|
406
|
+
1. 本地 Vite 启动在 127.0.0.1:9527
|
|
407
|
+
2. 映射代理域名:browser_set_proxy_rule({ domain: "p9527-test.tuwan.com", port: 9527 })
|
|
408
|
+
3. 免登访问页面:browser_navigate({ url: "http://p9527-test.tuwan.com/" })
|
|
409
|
+
-> 自动携带点点线上 Tuwan_Passport Cookie,无需改动系统 hosts!
|
|
410
|
+
|
|
411
|
+
// 方式 B:项目规则目录批量导入(推荐)
|
|
412
|
+
1. 项目中已存在 .whistle-rules 目录(含域名映射、接口 Mock 等多份规则)
|
|
413
|
+
2. 批量加载目录:browser_load_proxy_rules_dir({ rulesDir: "D:/projects/my-web/.whistle-rules" })
|
|
414
|
+
3. 直接按规则访问测试页面,全量代理与 Mock 立即生效。</div>
|
|
415
|
+
|
|
416
|
+
<div class="code-title"><span>流程 2:游客拦截 vs 正常登录态对比测试</span></div>
|
|
417
|
+
<div class="code-block" style="color: #93c5fd; font-size: 12px; margin-bottom: 12px;">// 1. 游客态验证(验证未登录拦截弹窗/导流流程)
|
|
418
|
+
browser_navigate({ url: "https://y.tuwan.com/activity/...", anonymous: true })
|
|
419
|
+
|
|
420
|
+
// 2. 默认登录态验证(自动携带默认账号正常参与活动)
|
|
421
|
+
browser_navigate({ url: "https://y.tuwan.com/activity/..." })
|
|
422
|
+
|
|
423
|
+
// 3. 指定测试账号(切换特定身份排查权限或对账)
|
|
424
|
+
browser_navigate({ url: "https://y.tuwan.com/activity/...", uid: "28689781" })</div>
|
|
425
|
+
|
|
426
|
+
<div class="code-title"><span>流程 3:交互排查与元素定位</span></div>
|
|
427
|
+
<div class="code-block" style="color: #93c5fd; font-size: 12px; margin-bottom: 0;">// 1. 获取页面结构化交互元素,杜绝盲猜选择器
|
|
428
|
+
const dom = browser_get_dom({ interactiveOnly: true })
|
|
429
|
+
|
|
430
|
+
// 2. 表单精准输入与回车键提交
|
|
431
|
+
browser_fill_text({ selector: "input#keyword", text: "测试内容" })
|
|
432
|
+
browser_press_key({ selector: "input#keyword", key: "Enter" })
|
|
433
|
+
|
|
434
|
+
// 3. 结果截图与控制台报错收集
|
|
435
|
+
browser_screenshot({ selector: ".result-box" })
|
|
436
|
+
const errors = browser_get_console_errors()</div>
|
|
437
|
+
</div>
|
|
393
438
|
</div>
|
|
394
439
|
|
|
395
440
|
<!-- TAB 4: 全局配置 -->
|
|
@@ -638,10 +683,9 @@ const DASHBOARD_HTML = `<!DOCTYPE html>
|
|
|
638
683
|
'# dd-playwright 自动化指南',
|
|
639
684
|
'本技能必须通过 dd-playwright MCP 服务提供的 browser_* 系列工具执行:',
|
|
640
685
|
'1. 登录态与身份切换:访问点点页面调用本 MCP 的 browser_navigate 自动注入激活账号免登;排查游客态或未登录拦截必须传 anonymous: true;指定测试账号传特定 uid。',
|
|
641
|
-
'2. 本地 Dev Server
|
|
686
|
+
'2. 本地 Dev Server 联调:严禁改动系统 hosts。支持 browser_set_proxy_rule 单条映射,或 browser_load_proxy_rules_dir 批量加载 .whistle-rules 目录(语法如:域名映射 p9527-test.tuwan.com http://127.0.0.1:9527、接口 Mock yapi.tuwan.com/act resBody://{mock.json}、官方文档 https://wproxy.org/whistle/rules/)。',
|
|
642
687
|
'3. 页面交互规范:定位困难时优先调用 browser_get_dom 提取可见元素结构,严禁盲猜选择器;表单填写使用 browser_fill_text,按键使用 browser_press_key。'
|
|
643
688
|
].join('\\n');
|
|
644
|
-
|
|
645
689
|
const cursorUrl = 'cursor://anysphere.cursor-deeplink/rule?name=' + encodeURIComponent(ruleName) + '&text=' + encodeURIComponent(compactRule);
|
|
646
690
|
window.location.href = cursorUrl;
|
|
647
691
|
}
|