{"id":28711,"date":"2025-03-15T11:19:10","date_gmt":"2025-03-15T03:19:10","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=28711"},"modified":"2025-03-15T11:19:10","modified_gmt":"2025-03-15T03:19:10","slug":"mcp-playwright","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/en\/mcp-playwright\/","title":{"rendered":"MCP Playwright\uff1a\u63d0\u4f9b\u6d4f\u89c8\u5668\u81ea\u52a8\u5316\u64cd\u4f5c\u7684MCP\u670d\u52a1"},"content":{"rendered":"<p>MCP-Playwright \u662f\u4e00\u4e2a\u7531 ExecuteAutomation \u5f00\u53d1\u5e76\u6258\u7ba1\u5728 GitHub \u4e0a\u7684\u5f00\u6e90\u5de5\u5177\u3002\u5b83\u57fa\u4e8e Playwright \u548c <a href=\"https:\/\/www.kdjingpai.com\/en\/model-context-protocol\/\">Model Context Protocol<\/a> (<a href=\"https:\/\/www.kdjingpai.com\/en\/model-context-protocol\/\">MCP<\/a>) \u534f\u8bae\uff0c\u76ee\u6807\u662f\u8ba9\u7528\u6237\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u6307\u4ee4\u5b9e\u73b0\u6d4f\u89c8\u5668\u81ea\u52a8\u5316\u548c API \u6d4b\u8bd5\u3002\u8fd9\u4e2a\u5de5\u5177\u9002\u5408\u5f00\u53d1\u8005\u548c\u6d4b\u8bd5\u4eba\u5458\uff0c\u53ef\u4ee5\u8fde\u63a5 <a href=\"https:\/\/www.kdjingpai.com\/en\/claudeanquanfubai\/\">Claude<\/a> \u7b49\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\uff0c\u901a\u8fc7\u7b80\u5355\u6587\u672c\u63a7\u5236\u6d4f\u89c8\u5668\u64cd\u4f5c\uff0c\u6bd4\u5982\u6253\u5f00\u7f51\u9875\u3001\u70b9\u51fb\u6309\u94ae\u3001\u586b\u5199\u8868\u5355\u3001\u622a\u56fe\uff0c\u6216\u53d1\u9001 API \u8bf7\u6c42\u3002\u5b83\u4e0d\u9700\u8981\u7528\u6237\u7f16\u5199\u590d\u6742\u4ee3\u7801\uff0c\u964d\u4f4e\u4e86\u4f7f\u7528\u95e8\u69db\u3002\u9879\u76ee\u76ee\u524d\u5904\u4e8e\u5f00\u53d1\u9636\u6bb5\uff0c\u529f\u80fd\u9010\u6b65\u5b8c\u5584\uff0c\u6b22\u8fce\u793e\u533a\u8d21\u732e\u4ee3\u7801\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-28712\" title=\"MCP Playwright\uff1a\u63d0\u4f9b\u6d4f\u89c8\u5668\u81ea\u52a8\u5316\u64cd\u4f5c\u7684MCP\u670d\u52a1-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/278cc7c60484527.jpg\" alt=\"MCP Playwright\uff1a\u63d0\u4f9b\u6d4f\u89c8\u5668\u81ea\u52a8\u5316\u64cd\u4f5c\u7684MCP\u670d\u52a1-1\" width=\"549\" height=\"289\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/278cc7c60484527.jpg 760w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/03\/278cc7c60484527-18x9.jpg 18w\" sizes=\"auto, (max-width: 549px) 100vw, 549px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li><strong>\u6d4f\u89c8\u5668\u81ea\u52a8\u5316<\/strong>\uff1a\u652f\u6301\u5bfc\u822a\u5230\u6307\u5b9a\u7f51\u9875\u3001\u70b9\u51fb\u5143\u7d20\u3001\u586b\u5199\u8f93\u5165\u6846\u3001\u9009\u62e9\u4e0b\u62c9\u9009\u9879\u7b49\u3002<\/li>\n<li><strong>API \u6d4b\u8bd5<\/strong>\uff1a\u80fd\u53d1\u9001 GET\u3001POST\u3001PUT\u3001PATCH\u3001DELETE \u8bf7\u6c42\uff0c\u5e76\u68c0\u67e5\u54cd\u5e94\u5185\u5bb9\u3002<\/li>\n<li><strong>\u622a\u56fe\u529f\u80fd<\/strong>\uff1a\u53ef\u622a\u53d6\u6574\u4e2a\u7f51\u9875\u6216\u7279\u5b9a\u533a\u57df\uff0c\u4fdd\u5b58\u4e3a\u56fe\u7247\u3002<\/li>\n<li><strong>\u6267\u884c JavaScript<\/strong>\uff1a\u80fd\u5728\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\u81ea\u5b9a\u4e49 JavaScript \u4ee3\u7801\u3002<\/li>\n<li><strong>\u83b7\u53d6\u63a7\u5236\u53f0\u65e5\u5fd7<\/strong>\uff1a\u63d0\u53d6\u6d4f\u89c8\u5668\u4e2d\u7684\u9519\u8bef\u3001\u8b66\u544a\u6216\u8c03\u8bd5\u4fe1\u606f\u3002<\/li>\n<li><strong>\u81ea\u7136\u8bed\u8a00\u63a7\u5236<\/strong>\uff1a\u901a\u8fc7 MCP \u534f\u8bae\u4e0e Claude \u7b49\u6a21\u578b\u8fde\u63a5\uff0c\u7528\u6587\u672c\u6307\u4ee4\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<p>MCP-Playwright \u9700\u8981\u7b80\u5355\u7684\u5b89\u88c5\u548c\u914d\u7f6e\u624d\u80fd\u4f7f\u7528\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\uff0c\u5e2e\u52a9\u4f60\u5feb\u901f\u4e0a\u624b\u3002<\/p>\n<h3>\u5b89\u88c5\u6d41\u7a0b<\/h3>\n<p>\u8981\u8fd0\u884c\u8fd9\u4e2a\u5de5\u5177\uff0c\u9700\u8981\u51c6\u5907\u73af\u5883\u5e76\u5b89\u88c5\u76f8\u5173\u7ec4\u4ef6\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li><strong>\u68c0\u67e5\u73af\u5883<\/strong>\n<ul>\n<li>\u786e\u4fdd\u7535\u8111\u5df2\u5b89\u88c5 Node.js\uff08\u5efa\u8bae\u4f7f\u7528\u6700\u65b0\u7a33\u5b9a\u7248\uff09\u3002<\/li>\n<li>\u9700\u8981\u652f\u6301 MCP \u7684\u5ba2\u6237\u7aef\uff0c\u6bd4\u5982 Claude Desktop Client\u3002<\/li>\n<li>\u5b89\u88c5 Git\uff0c\u7528\u4e8e\u4e0b\u8f7d\u4ee3\u7801\uff08\u53ef\u9009\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u4e0b\u8f7d\u9879\u76ee\uff08\u53ef\u9009\u624b\u52a8\u5b89\u88c5\uff09<\/strong>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u8fd0\u884c\uff1a\n<pre><code>git clone https:\/\/github.com\/executeautomation\/mcp-playwright.git\r\n<\/code><\/pre>\n<\/li>\n<li>\u8fdb\u5165\u9879\u76ee\u76ee\u5f55\uff1a\n<pre><code>cd mcp-playwright\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5b89\u88c5\u4f9d\u8d56<\/strong>\n<ul>\n<li>\u5728\u9879\u76ee\u76ee\u5f55\u8fd0\u884c\uff1a\n<pre><code>npm install\r\n<\/code><\/pre>\n<\/li>\n<li>\u8fd9\u4f1a\u5b89\u88c5 Playwright \u548c\u5176\u4ed6\u5fc5\u8981\u7ec4\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u76f4\u63a5\u901a\u8fc7 npm \u5b89\u88c5\uff08\u63a8\u8350\uff09<\/strong>\n<ul>\n<li>\u5982\u679c\u4e0d\u60f3\u624b\u52a8\u4e0b\u8f7d\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\uff1a\n<pre><code>npm install -g @executeautomation\/playwright-mcp-server\r\n<\/code><\/pre>\n<\/li>\n<li>\u8fd9\u4f1a\u5168\u5c40\u5b89\u88c5\u670d\u52a1\u5668\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u901a\u8fc7 Smithery \u5b89\u88c5\uff08\u9002\u7528\u4e8e Claude Desktop\uff09<\/strong>\n<ul>\n<li>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u81ea\u52a8\u5b89\u88c5\u5e76\u914d\u7f6e\uff1a\n<pre><code>npx -y @smithery\/cli install @executeautomation\/playwright-mcp-server --client claude\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u914d\u7f6e Claude Desktop<\/strong>\n<ul>\n<li>\u627e\u5230 Claude Desktop \u7684\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u5728\u7528\u6237\u76ee\u5f55\u4e0b\u7684 Claude \u6587\u4ef6\u5939\u4e2d\uff0c\u6587\u4ef6\u540d\u4e3a\u00a0<code>claude-desktop-config.json<\/code>\uff09\u3002<\/li>\n<li>\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a\n<pre><code>{\r\n\"mcpServers\": {\r\n\"playwright\": {\r\n\"<a href=\"https:\/\/www.kdjingpai.com\/en\/cohere\/\">command<\/a>\": \"npx\",\r\n\"args\": [\"-y\", \"@executeautomation\/playwright-mcp-server\"]\r\n}\r\n}\r\n}\r\n<\/code><\/pre>\n<\/li>\n<li>\u4fdd\u5b58\u540e\u91cd\u542f Claude Desktop\uff0c\u754c\u9762\u4e0a\u4f1a\u51fa\u73b0 \u201cAttach from MCP\u201d \u6309\u94ae\uff0c\u8868\u793a\u914d\u7f6e\u6210\u529f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u5982\u4f55\u4f7f\u7528<\/h3>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u7528\u81ea\u7136\u8bed\u8a00\u6307\u4ee4\u63a7\u5236\u6d4f\u89c8\u5668\u6216\u6d4b\u8bd5 API\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u64cd\u4f5c\u65b9\u6cd5\u3002<\/p>\n<h4>\u6d4f\u89c8\u5668\u81ea\u52a8\u5316<\/h4>\n<ul>\n<li><strong>\u6253\u5f00\u7f51\u9875<\/strong><br \/>\n\u5728 Claude Desktop \u8f93\u5165\uff1a<\/li>\n<\/ul>\n<pre><code>\u6253\u5f00\u7f51\u9875 https:\/\/example.com\r\n<\/code><\/pre>\n<p>\u5de5\u5177\u4f1a\u542f\u52a8\u6d4f\u89c8\u5668\u5e76\u52a0\u8f7d\u9875\u9762\u3002<\/p>\n<ul>\n<li><strong>\u70b9\u51fb\u5143\u7d20<\/strong><br \/>\n\u8f93\u5165\uff1a<\/li>\n<\/ul>\n<pre><code>\u70b9\u51fb\u9875\u9762\u4e0a\u7684\u767b\u5f55\u6309\u94ae\uff0c\u4f7f\u7528\u9009\u62e9\u5668 #loginBtn\r\n<\/code><\/pre>\n<p>\u5b83\u4f1a\u627e\u5230 ID \u4e3a\u00a0<code>loginBtn<\/code>\u00a0\u7684\u6309\u94ae\u5e76\u70b9\u51fb\u3002<\/p>\n<ul>\n<li><strong>\u586b\u5199\u8868\u5355<\/strong><br \/>\n\u8f93\u5165\uff1a<\/li>\n<\/ul>\n<pre><code>\u5728\u7528\u6237\u540d\u8f93\u5165\u6846\u586b\u5199 \"admin\"\uff0c\u4f7f\u7528\u9009\u62e9\u5668 #username\r\n\u5728\u5bc6\u7801\u8f93\u5165\u6846\u586b\u5199 \"123456\"\uff0c\u4f7f\u7528\u9009\u62e9\u5668 #password\r\n<\/code><\/pre>\n<p>\u5de5\u5177\u4f1a\u81ea\u52a8\u586b\u5165\u5185\u5bb9\u3002<\/p>\n<ul>\n<li><strong>\u622a\u56fe<\/strong><br \/>\n\u8f93\u5165\uff1a<\/li>\n<\/ul>\n<pre><code>\u622a\u53d6\u6574\u4e2a\u7f51\u9875\uff0c\u4fdd\u5b58\u4e3a \"page.png\"\r\n<\/code><\/pre>\n<p>\u622a\u56fe\u4f1a\u4fdd\u5b58\u5230\u5f53\u524d\u76ee\u5f55\u3002<\/p>\n<ul>\n<li><strong>\u8fd0\u884c JavaScript<\/strong><br \/>\n\u8f93\u5165\uff1a<\/li>\n<\/ul>\n<pre><code>\u5728\u6d4f\u89c8\u5668\u4e2d\u6267\u884c JavaScript \u4ee3\u7801 \"document.title\"\r\n<\/code><\/pre>\n<p>\u8fd4\u56de\u7f51\u9875\u6807\u9898\u3002<\/p>\n<ul>\n<li><strong>\u83b7\u53d6\u65e5\u5fd7<\/strong><br \/>\n\u8f93\u5165\uff1a<\/li>\n<\/ul>\n<pre><code>\u83b7\u53d6\u6d4f\u89c8\u5668\u63a7\u5236\u53f0\u65e5\u5fd7\uff0c\u53ea\u663e\u793a\u9519\u8bef\u4fe1\u606f\r\n<\/code><\/pre>\n<p>\u5de5\u5177\u4f1a\u8fd4\u56de\u9519\u8bef\u65e5\u5fd7\u3002<\/p>\n<h4>API \u6d4b\u8bd5<\/h4>\n<ul>\n<li><strong>\u53d1\u9001 GET \u8bf7\u6c42<\/strong><br \/>\n\u8f93\u5165\uff1a<\/li>\n<\/ul>\n<pre><code>\u5bf9 https:\/\/api.example.com\/data \u53d1\u9001 GET \u8bf7\u6c42\r\n<\/code><\/pre>\n<p>\u8fd4\u56de\u72b6\u6001\u7801\u548c\u6570\u636e\u3002<\/p>\n<ul>\n<li><strong>\u53d1\u9001 POST \u8bf7\u6c42<\/strong><br \/>\n\u8f93\u5165\uff1a<\/li>\n<\/ul>\n<pre><code>\u5bf9 https:\/\/api.example.com\/users \u53d1\u9001 POST \u8bf7\u6c42\uff0c\u6570\u636e\u4e3a {\"name\": \"TestUser\"}\r\n\u68c0\u67e5\u54cd\u5e94\u4e2d\u5305\u542b \"id\"\r\n<\/code><\/pre>\n<p>\u5de5\u5177\u4f1a\u9a8c\u8bc1\u7ed3\u679c\u3002<\/p>\n<ul>\n<li><strong>\u66f4\u65b0\u6570\u636e<\/strong><br \/>\n\u8f93\u5165\uff1a<\/li>\n<\/ul>\n<pre><code>\u5bf9 https:\/\/api.example.com\/users\/1 \u53d1\u9001 PUT \u8bf7\u6c42\uff0c\u6570\u636e\u4e3a {\"name\": \"NewUser\"}\r\n<\/code><\/pre>\n<p>\u6570\u636e\u4f1a\u88ab\u66f4\u65b0\u3002<\/p>\n<h3>\u64cd\u4f5c\u5b9e\u4f8b<\/h3>\n<p>\u5047\u8bbe\u4f60\u8981\u6d4b\u8bd5\u4e00\u4e2a\u767b\u5f55\u6d41\u7a0b\uff1a<\/p>\n<ol>\n<li>\u8f93\u5165\uff1a<\/li>\n<\/ol>\n<pre><code>\u6253\u5f00\u7f51\u9875 http:\/\/eaapp.somee.com\r\n<\/code><\/pre>\n<ol start=\"2\">\n<li>\u8f93\u5165\uff1a<\/li>\n<\/ol>\n<pre><code>\u70b9\u51fb\u9875\u9762\u4e0a\u7684\u767b\u5f55\u94fe\u63a5\uff0c\u4f7f\u7528\u9009\u62e9\u5668 #loginLink\r\n<\/code><\/pre>\n<ol start=\"3\">\n<li>\u8f93\u5165\uff1a<\/li>\n<\/ol>\n<pre><code>\u5728\u7528\u6237\u540d\u8f93\u5165\u6846\u586b\u5199 \"admin\"\uff0c\u4f7f\u7528\u9009\u62e9\u5668 #username\r\n\u5728\u5bc6\u7801\u8f93\u5165\u6846\u586b\u5199 \"password\"\uff0c\u4f7f\u7528\u9009\u62e9\u5668 #password\r\n\u70b9\u51fb\u767b\u5f55\u6309\u94ae\uff0c\u4f7f\u7528\u9009\u62e9\u5668 #loginBtn\r\n<\/code><\/pre>\n<ol start=\"4\">\n<li>\u8f93\u5165\uff1a<\/li>\n<\/ol>\n<pre><code>\u622a\u53d6\u6574\u4e2a\u7f51\u9875\uff0c\u4fdd\u5b58\u4e3a \"login_result.png\"\r\n<\/code><\/pre>\n<ol start=\"5\">\n<li>\u8f93\u5165\uff1a<\/li>\n<\/ol>\n<pre><code>\u5173\u95ed\u6d4f\u89c8\u5668\r\n<\/code><\/pre>\n<p>\u6574\u4e2a\u8fc7\u7a0b\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u5b8c\u6210\uff0c\u7b80\u5355\u76f4\u89c2\u3002<\/p>\n<h3>\u6d4b\u8bd5\u5de5\u5177<\/h3>\n<p>\u9879\u76ee\u4f7f\u7528 Jest \u8fdb\u884c\u6d4b\u8bd5\u3002\u5982\u679c\u4f60\u60f3\u9a8c\u8bc1\u529f\u80fd\uff0c\u53ef\u4ee5\u8fd0\u884c\u6d4b\u8bd5\uff1a<\/p>\n<ul>\n<li>\u5728\u7ec8\u7aef\u8f93\u5165\uff1a<\/li>\n<\/ul>\n<pre><code>npm test\r\n<\/code><\/pre>\n<ul>\n<li>\u5e26\u8986\u76d6\u7387\u62a5\u544a\uff1a\n<pre><code>npm run test:coverage\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<p>\u6d4b\u8bd5\u62a5\u544a\u4f1a\u751f\u6210\u5728\u00a0<code>coverage<\/code>\u00a0\u76ee\u5f55\u3002<\/p>\n<h3>\u6ce8\u610f\u4e8b\u9879<\/h3>\n<ul>\n<li>\u76ee\u524d\u5de5\u5177\u4e0d\u652f\u6301\u590d\u6742\u7684\u8eab\u4efd\u9a8c\u8bc1\u8bf7\u6c42\uff08\u5982 OAuth\uff09\u3002<\/li>\n<li>\u5982\u679c\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u67e5\u770b\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/executeautomation.github.io\/mcp-playwright\/\u3002<\/li>\n<li>\u9879\u76ee\u662f\u5f00\u6e90\u7684\uff0c\u4f60\u53ef\u4ee5 fork \u5e76\u63d0\u4ea4\u6539\u8fdb\u5efa\u8bae\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>MCP-Playwright \u662f\u4e00\u4e2a\u7531 ExecuteAutomation \u5f00\u53d1\u5e76\u6258\u7ba1\u5728 GitHub \u4e0a\u7684\u5f00\u6e90\u5de5\u5177\u3002\u5b83\u57fa\u4e8e Playwright \u548c Model Context Protocol (MCP) \u534f\u8bae\uff0c\u76ee\u6807\u662f\u8ba9\u7528\u6237\u901a\u8fc7\u81ea\u7136\u8bed\u8a00&#8230;<\/p>\n","protected":false},"author":1,"featured_media":62043,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[230,387],"class_list":["post-28711","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tool","tag-aikaiyuanxiangmu","tag-mcpfuwu"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/posts\/28711","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/comments?post=28711"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/posts\/28711\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/media\/62043"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/media?parent=28711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/categories?post=28711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/en\/wp-json\/wp\/v2\/tags?post=28711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}