{"id":125,"date":"2026-07-13T11:09:00","date_gmt":"2026-07-13T03:09:00","guid":{"rendered":"https:\/\/www.deartester.com\/index.php\/2026\/07\/13\/%e6%97%a0%e4%bb%a3%e7%a0%81%e8%87%aa%e5%8a%a8%e5%8c%96%e6%b5%8b%e8%af%95%e5%ae%9e%e6%93%8d%ef%bc%9aplaywright%e5%ae%9e%e7%8e%b0%e8%b7%a8%e6%b5%8f%e8%a7%88%e5%99%a8%e6%b5%8b%e8%af%95\/"},"modified":"2026-09-03T23:17:43","modified_gmt":"2026-09-03T15:17:43","slug":"%e6%97%a0%e4%bb%a3%e7%a0%81%e8%87%aa%e5%8a%a8%e5%8c%96%e6%b5%8b%e8%af%95%e5%ae%9e%e6%93%8d%ef%bc%9aplaywright%e5%ae%9e%e7%8e%b0%e8%b7%a8%e6%b5%8f%e8%a7%88%e5%99%a8%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/www.deartester.com\/index.php\/2026\/07\/13\/%e6%97%a0%e4%bb%a3%e7%a0%81%e8%87%aa%e5%8a%a8%e5%8c%96%e6%b5%8b%e8%af%95%e5%ae%9e%e6%93%8d%ef%bc%9aplaywright%e5%ae%9e%e7%8e%b0%e8%b7%a8%e6%b5%8f%e8%a7%88%e5%99%a8%e6%b5%8b%e8%af%95\/","title":{"rendered":"\u65e0\u4ee3\u7801\u81ea\u52a8\u5316\u6d4b\u8bd5\u5b9e\u64cd\uff1aPlaywright\u5b9e\u73b0\u8de8\u6d4f\u89c8\u5668\u6d4b\u8bd5"},"content":{"rendered":"<p style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 0px 0px 10px;font-weight: bold;color: rgb(21, 101, 192);font-size: 16px;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\ud83d\udccc \u5bfc\u8bfb<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 0px;text-indent: 2em;\"><span leaf=\"\">\u5982\u679c\u4f60\u5728\u6d4b\u8bd5\u56e2\u961f\u91cc\u5f85\u8fc7\u4e00\u6bb5\u65f6\u95f4\uff0c\u4e00\u5b9a\u5bf9 Selenium \u7684\u90a3\u4e9b\u201c\u8001\u6bdb\u75c5\u201d\u4e0d\u964c\u751f\uff1a\u5143\u7d20\u8fd8\u6ca1\u52a0\u8f7d\u5b8c\u5c31\u62a5\u627e\u4e0d\u5230\u3001\u7b49\u5f85\u903b\u8f91\u8981\u81ea\u5df1\u5199\u4e00\u5806&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">WebDriverWait<\/span><\/code><span leaf=\"\">\u3001\u5207\u6362\u6d4f\u89c8\u5668\u8981\u88c5\u4e0d\u540c\u7684 driver\u3001\u51fa\u4e86\u9519\u53ea\u80fd\u9760\u622a\u56fe\u548c\u65e5\u5fd7\u201c\u731c\u201d\u5230\u5e95\u54ea\u91cc\u6302\u4e86\u3002\u66f4\u9ebb\u70e6\u7684\u662f\uff0c\u5f53\u4f60\u60f3\u8986\u76d6 Chrome\u3001Firefox\u3001Safari \u4e09\u79cd\u5185\u6838\u65f6\uff0c\u7ef4\u62a4\u6210\u672c\u51e0\u4e4e\u662f\u6210\u500d\u589e\u957f\uff0c\u811a\u672c\u8981\u4e3a\u6bcf\u4e2a\u6d4f\u89c8\u5668\u5355\u72ec\u8c03\u4f18\uff0cCI \u77e9\u9635\u4e00\u5c55\u5f00\uff0c\u65f6\u95f4\u6210\u672c\u76f4\u7ebf\u4e0a\u5347\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 10px 0px 0px;text-indent: 2em;\"><span leaf=\"\">\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u8d8a\u6765\u8d8a\u591a\u56e2\u961f\u628a\u76ee\u5149\u6295\u5411\u4e86&nbsp;<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">Playwright<\/span><\/strong><span leaf=\"\">\u3002\u5b83\u7531 Microsoft \u51fa\u54c1\uff0c\u5929\u751f\u5e26\u7740\u51e0\u9879\u201c\u6740\u624b\u950f\u201d\uff1a<\/span><span style=\"color: rgb(21, 101, 192);font-weight: bold;\"><span leaf=\"\">\u81ea\u52a8\u7b49\u5f85\u673a\u5236<\/span><\/span><span leaf=\"\">\u8ba9\u811a\u672c\u4e0d\u518d\u548c\u65f6\u5e8f\u8f83\u52b2\u3001<\/span><span style=\"color: rgb(21, 101, 192);font-weight: bold;\"><span leaf=\"\">\u6d4f\u89c8\u5668\u4e0a\u4e0b\u6587\u9694\u79bb<\/span><\/span><span leaf=\"\">\u8ba9\u6bcf\u4e2a\u6d4b\u8bd5\u7528\u4f8b\u5e72\u51c0\u72ec\u7acb\u3001<\/span><span style=\"color: rgb(21, 101, 192);font-weight: bold;\"><span leaf=\"\">codegen \u96f6\u4ee3\u7801\u5f55\u5236<\/span><\/span><span leaf=\"\">\u8ba9\u65b0\u624b\u4e5f\u80fd\u5728\u51e0\u5206\u949f\u5185\u4ea7\u51fa\u53ef\u7528\u811a\u672c\uff0c\u8fd8\u6709&nbsp;<\/span><span style=\"color: rgb(21, 101, 192);font-weight: bold;\"><span leaf=\"\">trace viewer<\/span><\/span><span leaf=\"\">&nbsp;\u8fd9\u79cd\u80fd\u9010\u5e27\u56de\u653e\u7684\u5f3a\u5927\u8c03\u8bd5\u5de5\u5177\u3002\u672c\u6587\u5c31\u5e26\u4f60\u4ece\u96f6\u8d70\u4e00\u904d\uff1a\u5982\u4f55\u7528 Playwright \u628a\u4e00\u5957\u811a\u672c\u8dd1\u904d\u4e09\u5927\u6d4f\u89c8\u5668\uff0c\u5e76\u6700\u7ec8\u63a5\u8fdb CI\/CD \u6d41\u6c34\u7ebf\u3002\u65e0\u8bba\u4f60\u662f\u521a\u63a5\u89e6 Playwright \u7684\u6d4b\u8bd5\u5de5\u7a0b\u5e08\uff0c\u8fd8\u662f\u6b63\u51c6\u5907\u66ff\u6362\u8001\u65e7 Selenium \u6846\u67b6\u7684\u6280\u672f\u8d1f\u8d23\u4eba\uff0c\u8fd9\u7bc7\u6587\u7ae0\u90fd\u80fd\u7ed9\u4f60\u4e00\u4efd\u53ef\u76f4\u63a5\u7167\u505a\u7684\u843d\u5730\u8def\u7ebf\u56fe\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 10px 0px 0px;text-indent: 2em;\"><span leaf=\"\"><br  \/><\/span><\/p>\n<p data-pm-slice=\"0 0 []\" style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"font-size: 12px;\">\ud83d\udcf7 \u56fe1\uff1aPlaywright \u67b6\u6784\u56fe\uff08\u6d4b\u8bd5 API \u2192 \u6838\u5fc3\u5f15\u64ce \u2192 \u6d4f\u89c8\u5668<\/span>\uff09<\/span><\/p>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000475\" data-s=\"300,640\" data-type=\"png\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/BWmfcibGhS1K4yDVTuLsh40DgJy4m8zE5Cd0eEr3QtkwRtPpSedYRgIFA2WPaHtWZ1SknicHRvDjxkfexmlicW70DVPbdCKHWLf1iaHnwBHIKico\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 18px;color: rgb(26, 26, 46);border-left: 4px solid rgb(21, 101, 192);padding-left: 12px;margin: 36px 0px 16px;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u4e00\u3001Playwright \u662f\u4ec0\u4e48\uff1a\u4e00\u4e2a\u88ab\u5fae\u8f6f\u62bc\u6ce8\u7684\u73b0\u4ee3\u6d4b\u8bd5\u6846\u67b6<\/span><\/h2>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5728\u6b63\u5f0f\u52a8\u624b\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u628a\u201cPlaywright \u5230\u5e95\u662f\u4ec0\u4e48\u201d\u8fd9\u4ef6\u4e8b\u8bb2\u6e05\u695a\u3002\u7b80\u5355\u6765\u8bf4\uff0c<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">Playwright \u662f\u7531 Microsoft \u5f00\u6e90\u5e76\u7ef4\u62a4\u7684\u4e00\u5957\u7aef\u5230\u7aef\uff08E2E\uff09\u81ea\u52a8\u5316\u6d4b\u8bd5\u6846\u67b6<\/span><\/strong><span leaf=\"\">\uff0c\u5b83\u7684\u76ee\u6807\u662f\u7528\u4e00\u5957\u7edf\u4e00\u3001\u7b80\u6d01\u7684 API\uff0c\u9a71\u52a8\u5e02\u9762\u4e0a\u4e3b\u6d41\u7684\u4e09\u5927\u6d4f\u89c8\u5668\u5185\u6838\u2014\u2014Chromium\u3001Firefox \u548c WebKit\u2014\u2014\u5b8c\u6210\u771f\u5b9e\u7684\u7528\u6237\u64cd\u4f5c\u6a21\u62df\u3002\u5b83\u6700\u521d\u5728 2020 \u5e74\u53d1\u5e03\uff0c\u6838\u5fc3\u56e2\u961f\u6b63\u662f\u5f53\u5e74 Puppeteer \u7684\u90e8\u5206\u539f\u73ed\u4eba\u9a6c\uff0c\u56e0\u6b64\u5728\u534f\u8bae\u5c42\u9762\u76f4\u63a5\u57fa\u4e8e\u6d4f\u89c8\u5668\u81ea\u5e26\u7684 DevTools Protocol\uff08WebKit \u7528\u81ea\u6709 CDP \u517c\u5bb9\u534f\u8bae\uff09\uff0c\u907f\u5f00\u4e86\u4f20\u7edf Selenium \u90a3\u79cd\u201c\u6bcf\u4e2a\u6d4f\u89c8\u5668\u5404\u88c5\u4e00\u4e2a driver\u201d\u7684\u7e41\u7410\u6a21\u578b\u3002\u8fd9\u79cd\u201c\u539f\u751f\u534f\u8bae\u76f4\u8fde\u201d\u7684\u67b6\u6784\uff0c\u662f\u5b83\u901f\u5ea6\u5feb\u3001\u53c8\u7a33\u7684\u6839\u672c\u539f\u56e0\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u548c\u8001\u724c\u7684 Selenium \u76f8\u6bd4\uff0cPlaywright \u7684\u4f53\u9a8c\u5dee\u5f02\u662f\u201c\u7528\u8fc7\u5c31\u56de\u4e0d\u53bb\u201d\u7ea7\u522b\u7684\u3002\u7b2c\u4e00\uff0c<\/span><span style=\"color: rgb(21, 101, 192);font-weight: bold;\"><span leaf=\"\">API \u8bbe\u8ba1\u66f4\u8d34\u5408\u73b0\u4ee3 Web<\/span><\/span><span leaf=\"\">\uff1a\u4f60\u4e0d\u7528\u518d\u53bb\u62fc&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">By.id<\/span><\/code><span leaf=\"\">\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">By.xpath<\/span><\/code><span leaf=\"\">&nbsp;\u90a3\u79cd\u5197\u957f\u5199\u6cd5\uff0c\u4e00\u4e2a&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.locator('.btn')<\/span><\/code><span leaf=\"\">&nbsp;\u5c31\u80fd\u7cbe\u51c6\u5b9a\u4f4d\u5143\u7d20\uff0c\u8fd8\u652f\u6301&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">getByRole<\/span><\/code><span leaf=\"\">\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">getByText<\/span><\/code><span leaf=\"\">&nbsp;\u8fd9\u7c7b\u8bed\u4e49\u5316\u5b9a\u4f4d\uff0c\u53ef\u8bfb\u6027\u66f4\u597d\u3002\u7b2c\u4e8c\uff0c<\/span><span style=\"color: rgb(21, 101, 192);font-weight: bold;\"><span leaf=\"\">\u81ea\u52a8\u7b49\u5f85\uff08Auto-waiting\uff09<\/span><\/span><span leaf=\"\">\u662f\u9ed8\u8ba4\u884c\u4e3a\uff1a\u5728\u70b9\u51fb\u6216\u8f93\u5165\u4e4b\u524d\uff0c\u6846\u67b6\u4f1a\u81ea\u52a8\u786e\u8ba4\u5143\u7d20\u201c\u53ef\u89c1\u3001\u7a33\u5b9a\u3001\u53ef\u63a5\u6536\u4e8b\u4ef6\u3001\u672a\u88ab\u906e\u6321\u201d\uff0c\u5927\u5e45\u51cf\u5c11 flaky test\u3002\u7b2c\u4e09\uff0c<\/span><strong><span leaf=\"\">\u591a\u8bed\u8a00 SDK \u9f50\u5907<\/span><\/strong><span leaf=\"\">\uff1aJavaScript\/TypeScript\u3001Python\u3001Java\u3001.NET \u56db\u79cd\u90fd\u80fd\u7528\uff0c\u56e2\u961f\u53ef\u4ee5\u9009\u81ea\u5df1\u6700\u719f\u6089\u7684\u6808\uff0c\u4e0d\u5fc5\u4e3a\u4e86\u6d4b\u8bd5\u6846\u67b6\u800c\u5207\u6362\u4e3b\u8bed\u8a00\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5728\u6d4f\u89c8\u5668\u8986\u76d6\u4e0a\uff0cPlaywright \u652f\u6301\u5f97\u5f88\u201c\u5f7b\u5e95\u201d\u3002<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">Chromium<\/span><\/strong><span leaf=\"\">&nbsp;\u4e00\u8109\u540c\u65f6\u8986\u76d6 Google Chrome \u548c Microsoft Edge\uff1b<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">Firefox<\/span><\/strong><span leaf=\"\">&nbsp;\u57fa\u4e8e Gecko \u5185\u6838\uff0c\u80fd\u66b4\u9732 Firefox \u7279\u6709\u7684\u6e32\u67d3\u95ee\u9898\uff1b<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">WebKit<\/span><\/strong><span leaf=\"\">&nbsp;\u5219\u662f Safari \u7684\u5185\u6838\uff0c\u8fc7\u53bb Mac\/iOS \u4e0a\u7684\u517c\u5bb9\u6027 bug \u5f80\u5f80\u53ea\u6709\u5b83\u624d\u80fd\u590d\u73b0\u3002\u8fd9\u610f\u5473\u7740\u4f60\u5199\u7684<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u540c\u4e00\u4efd\u6d4b\u8bd5\u811a\u672c\uff0c\u65e0\u9700\u6539\u5199\u5c31\u80fd\u5728\u4e09\u79cd\u5185\u6838\u4e0a\u8dd1<\/span><\/strong><span leaf=\"\">\uff0c\u8986\u76d6\u7387\u76f4\u63a5\u62c9\u6ee1\uff0c\u800c\u7ef4\u62a4\u6210\u672c\u53ea\u589e\u52a0\u4e00\u70b9\u70b9\u914d\u7f6e\u3002\u9664\u6b64\u4e4b\u5916\uff0cPlaywright \u8fd8\u80fd\u9a71\u52a8\u65e0\u5934\u6d4f\u89c8\u5668\u3001\u79fb\u52a8\u7aef\u6a21\u62df\uff08\u901a\u8fc7 viewport + \u8bbe\u5907\u63cf\u8ff0\u7b26\uff09\u3001\u4ee5\u53ca\u63a2\u6d4b\u201c\u504f\u597d\u51cf\u5c11\u52a8\u753b\u201d\u7b49\u65e0\u969c\u788d\u573a\u666f\uff0c\u8986\u76d6\u9762\u8fdc\u8d85\u4f20\u7edf\u65b9\u6848\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u4ece\u751f\u6001\u89d2\u5ea6\u770b\uff0c\u5fae\u8f6f\u7684\u80cc\u4e66\u610f\u5473\u7740\u5b83\u66f4\u65b0\u8282\u594f\u5feb\u3001\u6587\u6863\u5b8c\u5584\u3001Issue \u54cd\u5e94\u79ef\u6781\uff0c\u5df2\u7ecf\u5f62\u6210\u7a33\u5b9a\u7684\u793e\u533a\u4e0e\u5927\u91cf\u7b2c\u4e09\u65b9\u63d2\u4ef6\uff08\u5982&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">@playwright\/test<\/span><\/code><span leaf=\"\">&nbsp;\u7684 fixture \u4f53\u7cfb\u3001\u53ef\u89c6\u5316\u62a5\u544a\u3001\u5e76\u884c\u5206\u7247\uff09\u3002\u5bf9\u4e8e\u6b63\u5728\u9009\u578b\u6216\u51c6\u5907\u8fc1\u79fb\u7684\u56e2\u961f\u6765\u8bf4\uff0c\u9009\u62e9 Playwright \u57fa\u672c\u7b49\u540c\u4e8e\u9009\u62e9\u4e86\u4e00\u6761\u201c\u5c11\u8e29\u5751\u3001\u957f\u671f\u53ef\u7ef4\u62a4\u201d\u7684\u8def\u7ebf\u3002\u5b89\u88c5\u65b9\u5f0f\u4e5f\u975e\u5e38\u53cb\u597d\uff0c\u57fa\u672c\u662f\u201c\u9009\u4f60\u987a\u624b\u7684\u5305\u7ba1\u7406\u5668\u201d\u5373\u53ef\uff1a\u524d\u7aef\u9879\u76ee\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npm<\/span><\/code><span leaf=\"\">\uff0cPython \u9879\u76ee\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">pip install playwright<\/span><\/code><span leaf=\"\">\uff0cMac \u4e0a\u751a\u81f3\u80fd\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">brew install --cask playwright<\/span><\/code><span leaf=\"\">&nbsp;\u76f4\u63a5\u88c5\u5e26 GUI \u7684\u8c03\u8bd5\u5de5\u5177\u3002\u63a5\u4e0b\u6765\u8fd9\u4e00\u7ae0\uff0c\u6211\u4eec\u5c31\u4ece\u5b89\u88c5\u5f00\u59cb\uff0c30 \u79d2\u542f\u52a8\u4f60\u7684\u7b2c\u4e00\u4e2a\u201c\u65e0\u4ee3\u7801\u201d\u6d4b\u8bd5\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u8865\u5145\u4e00\u70b9\uff1a\u5e76\u975e\u6240\u6709\u9879\u76ee\u90fd\u975e Playwright \u4e0d\u53ef\u3002\u5982\u679c\u4f60\u7684\u7cfb\u7edf\u53ea\u8dd1\u5728\u5355\u4e00\u5185\u6838\u3001\u4e14\u56e2\u961f\u5df2\u88ab Selenium \u6df1\u5ea6\u7ed1\u5b9a\u3001\u5b58\u91cf\u7528\u4f8b\u91cf\u6781\u5927\uff0c\u8fc1\u79fb\u6210\u672c\u9700\u8981\u4ed4\u7ec6\u6743\u8861\u3002\u4f46\u5bf9\u4e8e\u65b0\u9879\u76ee\u3001\u9700\u8981\u591a\u6d4f\u89c8\u5668\u8986\u76d6\u3001\u6216\u53d7\u591f\u4e86 flaky test \u7684\u56e2\u961f\uff0cPlaywright \u51e0\u4e4e\u662f\u4e0d\u5047\u601d\u7d22\u7684\u9996\u9009\u3002\u5b83\u8fde\u79fb\u52a8\u7aef\u6a21\u62df\u3001\u6697\u9ed1\u6a21\u5f0f\u3001reduced motion \u7b49\u53ef\u8bbf\u95ee\u6027\u573a\u666f\u90fd\u539f\u751f\u652f\u6301\uff0c\u672a\u6765\u6269\u5c55\u7a7a\u95f4\u5f88\u5927\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u8fd8\u6709\u4e00\u4e2a\u5e38\u88ab\u5ffd\u7565\u7684\u4f18\u52bf\uff1aPlaywright \u7684<\/span><strong><span leaf=\"\">\u534f\u8bae\u5c42\u76f4\u8fde<\/span><\/strong><span leaf=\"\">\u8bbe\u8ba1\uff0c\u4f7f\u5176\u542f\u52a8\u6d4f\u89c8\u5668\u3001\u6267\u884c\u64cd\u4f5c\u7684\u901f\u5ea6\u660e\u663e\u5feb\u4e8e\u4f20\u7edf\u201c\u9a71\u52a8\u8fdb\u7a0b\u201d\u6a21\u5f0f\uff0c\u5728\u5927\u89c4\u6a21\u56de\u5f52\u91cc\u80fd\u7701\u4e0b\u53ef\u89c2\u7684\u7b49\u5f85\u65f6\u95f4\u3002\u914d\u5408\u5185\u7f6e\u5e76\u884c\uff0c\u51e0\u767e\u6761\u7528\u4f8b\u4e5f\u80fd\u5728\u5206\u949f\u7ea7\u8dd1\u5b8c\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u5f88\u591a\u56e2\u961f\u5728\u8fc1\u79fb\u540e\uff0c\u4e0d\u4ec5\u8986\u76d6\u7387\u4e0a\u53bb\u4e86\uff0c\u5355\u6b21\u56de\u5f52\u65f6\u957f\u53cd\u800c\u66f4\u77ed\u4e86\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5982\u679c\u56e2\u961f\u6b63\u5728\u505a\u6280\u672f\u9009\u578b\uff0c\u6211\u5efa\u8bae\u7528\u4e00\u4e2a\u5c0f spike\uff081-2 \u5929\uff09\u8dd1\u901a\u201c\u5f55\u5236\u2192\u4e09\u6d4f\u89c8\u5668\u2192CI\u201d\u7684\u6700\u5c0f\u95ed\u73af\uff0c\u7528\u771f\u5b9e\u4e1a\u52a1\u9875\u9762\u9a8c\u8bc1\uff0c\u518d\u51b3\u5b9a\u5168\u9762\u94fa\u5f00\u3002Playwright \u7684\u8fc1\u79fb\u6210\u672c\u5176\u5b9e\u4e0d\u9ad8\uff1a\u5b83\u7684 API \u4e0e\u591a\u6570\u73b0\u4ee3\u6846\u67b6\u6982\u5ff5\u76f8\u901a\uff0c\u8001 Selenium \u7528\u4f8b\u4e5f\u80fd\u9010\u6b65\u62bd\u79bb\u91cd\u5199\u3002\u5173\u952e\u662f\u5148\u8ba9\u56e2\u961f\u5c1d\u5230\u201c\u4e00\u6b21\u7f16\u5199\u3001\u4e09\u7aef\u8986\u76d6\u201d\u7684\u751c\u5934\uff0c\u63a8\u5e7f\u963b\u529b\u4f1a\u5c0f\u5f88\u591a\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u8fd8\u8981\u63d0\u9192\u4e00\u70b9\u5fc3\u6001\uff1a\u8de8\u6d4f\u89c8\u5668\u6d4b\u8bd5\u4e0d\u662f\u201c\u5199\u5b8c\u5c31\u4e00\u52b3\u6c38\u9038\u201d\u3002\u6d4f\u89c8\u5668\u5927\u7248\u672c\u4f1a\u8fed\u4ee3\uff0c\u4e1a\u52a1\u4f1a\u6539\u7248\uff0c\u5957\u4ef6\u9700\u8981\u50cf\u4ee3\u7801\u4e00\u6837\u6301\u7eed\u7ef4\u62a4\u3002\u597d\u6d88\u606f\u662f Playwright \u7684\u5347\u7ea7\u5f88\u5e73\u6ed1\uff0c\u5b98\u65b9\u5bf9\u7834\u574f\u6027\u53d8\u66f4\u6781\u5176\u514b\u5236\uff0c\u57fa\u672c\u9075\u5faa\u8bed\u4e49\u5316\u7248\u672c\u3002\u628a\u6d4b\u8bd5\u4f9d\u8d56\u7eb3\u5165\u5b9a\u671f\u5347\u7ea7\u8ba1\u5212\uff0c\u6bd4\u201c\u9501\u6b7b\u7248\u672c\u591a\u5e74\u4e0d\u66f4\u65b0\u201d\u8981\u5065\u5eb7\u5f97\u591a\uff0c\u4e5f\u80fd\u6301\u7eed\u4eab\u53d7\u65b0\u5185\u6838\u5e26\u6765\u7684\u517c\u5bb9\u6027\u7ea2\u5229\u3002<\/span><\/p>\n<p style=\"margin: 0px;color: rgb(13, 71, 161);\"><strong><span leaf=\"\">\ud83d\udca1 \u5c0f\u7ed3\uff1a<\/span><\/strong><span leaf=\"\">Playwright = \u5fae\u8f6f\u51fa\u54c1 + \u4e09\u5185\u6838\u7edf\u4e00\u9a71\u52a8 + \u81ea\u52a8\u7b49\u5f85 + \u591a\u8bed\u8a00 SDK\uff0c\u662f\u8986\u76d6\u8de8\u6d4f\u89c8\u5668 Web \u6d4b\u8bd5\u7684\u73b0\u4ee3\u9996\u9009\u6846\u67b6\u3002<\/span><\/p>\n<section><span leaf=\"\"><br  \/><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 18px;color: rgb(26, 26, 46);border-left: 4px solid rgb(21, 101, 192);padding-left: 12px;margin: 36px 0px 16px;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u4e8c\u3001\u73af\u5883\u642d\u5efa\uff1a30 \u79d2\u542f\u52a8\u65e0\u4ee3\u7801\u6d4b\u8bd5<\/span><\/h2>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5f88\u591a\u6d4b\u8bd5\u540c\u5b66\u4e00\u542c\u201c\u81ea\u52a8\u5316\u6846\u67b6\u201d\u5c31\u5934\u5927\uff0c\u89c9\u5f97\u8981\u914d\u4e00\u5806\u73af\u5883\u3002\u4f46 Playwright \u7684\u5165\u95e8\u95e8\u69db\u4f4e\u5230\u79bb\u8c31\uff0c<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u4e24\u6761\u547d\u4ee4\u5c31\u80fd\u628a\u6574\u5957\u8fd0\u884c\u65f6\u88c5\u597d<\/span><\/strong><span leaf=\"\">\u3002\u4e0b\u9762\u4ee5 Node.js \u9879\u76ee\u4e3a\u4f8b\uff0c\u5728\u4f60\u51c6\u5907\u597d\u7684\u7a7a\u76ee\u5f55\u91cc\u4f9d\u6b21\u6267\u884c\uff1a<\/span><\/p>\n<p><code style=\"font-family: &quot;Courier New&quot;, monospace;font-size: 13px;color: rgb(224, 232, 240);line-height: 1.7;display: block;\"><span style=\"color: rgb(126, 231, 135);\"><span leaf=\"\"># 1. \u5b89\u88c5\u6d4b\u8bd5\u8fd0\u884c\u5668\uff08\u5f00\u53d1\u4f9d\u8d56\uff09<\/span><\/span><span leaf=\"\">&nbsp;<\/span><span style=\"color: rgb(255, 123, 114);\"><span leaf=\"\">npm<\/span><\/span><span leaf=\"\">&nbsp;install -D @playwright\/test&nbsp;<\/span><span style=\"color: rgb(126, 231, 135);\"><span leaf=\"\"># 2. \u4e0b\u8f7d\u4e09\u5927\u6d4f\u89c8\u5668\u5185\u6838\u53ca\u7cfb\u7edf\u4f9d\u8d56<\/span><\/span><span leaf=\"\">&nbsp;<\/span><span style=\"color: rgb(255, 123, 114);\"><span leaf=\"\">npx<\/span><\/span><span leaf=\"\">&nbsp;playwright install&nbsp;<\/span><span style=\"color: rgb(126, 231, 135);\"><span leaf=\"\"># 3. \u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f<\/span><\/span><span leaf=\"\">&nbsp;<\/span><span style=\"color: rgb(255, 123, 114);\"><span leaf=\"\">npx<\/span><\/span><span leaf=\"\">&nbsp;playwright --version&nbsp;<\/span><span style=\"color: rgb(165, 214, 255);\"><span leaf=\"\"># \u8f93\u51fa\u793a\u4f8b\uff1aVersion 1.48.0<\/span><\/span><\/code><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright install<\/span><\/code><span leaf=\"\">&nbsp;\u8fd9\u4e00\u6b65\u4f1a\u81ea\u52a8\u62c9\u53d6 Chromium\u3001Firefox\u3001WebKit \u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u4e0d\u9700\u8981\u4f60\u624b\u52a8\u53bb\u5b98\u7f51\u4e0b\u8f7d driver<\/span><\/strong><span leaf=\"\">\u2014\u2014\u8fd9\u6b63\u662f\u5b83\u6bd4 Selenium \u7701\u5fc3\u7684\u7b2c\u4e00\u5904\u3002\u5728 Linux \u670d\u52a1\u5668\u4e0a\u5982\u679c\u63d0\u793a\u7f3a\u5c11\u7cfb\u7edf\u5e93\uff0c\u8865\u4e00\u53e5&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright install-deps<\/span><\/code><span leaf=\"\">&nbsp;\u5373\u53ef\u8ba9\u6846\u67b6\u5e2e\u4f60\u88c5\u597d\u4f9d\u8d56\u3002\u9700\u8981\u7279\u522b\u63d0\u9192\u7684\u662f\uff0c<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">playwright install<\/span><\/code><span leaf=\"\">&nbsp;\u4e0b\u8f7d\u7684\u662f\u6d4f\u89c8\u5668\u5185\u6838\u672c\u4f53\uff0c\u800c&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">install-deps<\/span><\/code><span leaf=\"\">&nbsp;\u88c5\u7684\u662f\u64cd\u4f5c\u7cfb\u7edf\u5c42\u9762\u7684\u5171\u4eab\u5e93\uff08\u5982\u5b57\u4f53\u3001SSL \u5e93\uff09\uff0c\u4e24\u8005\u7f3a\u4e00\u4e0d\u53ef\uff0c\u5426\u5219 CI \u4e0a\u5e38\u51fa\u73b0\u201c\u6d4f\u89c8\u5668\u542f\u52a8\u5373\u5d29\u6e83\u201d\u7684\u8be1\u5f02\u62a5\u9519\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u771f\u6b63\u8ba9\u65b0\u624b\u6b22\u547c\u7684\uff0c\u662f Playwright \u81ea\u5e26\u7684&nbsp;<\/span><span style=\"color: rgb(21, 101, 192);font-weight: bold;\"><span leaf=\"\">codegen \u5f55\u5236\u5668<\/span><\/span><span leaf=\"\">\u3002\u4f60\u53ef\u4ee5\u628a\u5b83\u7406\u89e3\u6210\u4e00\u4e2a\u201c\u52a8\u4f5c\u8bb0\u5f55\u4eea\u201d\uff1a\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u4f60\u624b\u52a8\u70b9\u54ea\u91cc\u3001\u8f93\u4ec0\u4e48\u3001\u5220\u4ec0\u4e48\uff0c\u5b83\u5c31\u5b9e\u65f6\u628a\u8fd9\u4e9b\u64cd\u4f5c\u7ffb\u8bd1\u6210\u53ef\u6267\u884c\u7684\u6d4b\u8bd5\u4ee3\u7801\u3002\u96f6\u4ee3\u7801\u57fa\u7840\u4e5f\u80fd\u5728\u51e0\u5206\u949f\u5185\u62e5\u6709\u4e00\u4efd\u80fd\u8dd1\u7684\u811a\u672c\u3002\u6765\u770b\u5177\u4f53\u6f14\u793a\uff1a<\/span><\/p>\n<p><code style=\"font-family: &quot;Courier New&quot;, monospace;font-size: 13px;color: rgb(224, 232, 240);line-height: 1.7;display: block;\"><span style=\"color: rgb(126, 231, 135);\"><span leaf=\"\"># \u542f\u52a8\u5f55\u5236\u5668\uff0c\u76ee\u6807\u7ad9\u70b9\u662f\u5b98\u65b9 TodoMVC \u6f14\u793a\u9875<\/span><\/span><span leaf=\"\">&nbsp;<\/span><span style=\"color: rgb(255, 123, 114);\"><span leaf=\"\">npx<\/span><\/span><span leaf=\"\">&nbsp;playwright codegen https:\/\/demo.playwright.dev\/todomvc\/<\/span><\/code><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u6267\u884c\u540e\uff0c\u4f1a\u5f39\u51fa\u4e00\u4e2a\u771f\u5b9e\u7684\u6d4f\u89c8\u5668\u7a97\u53e3\u548c\u5de6\u4fa7\u7684\u5f55\u5236\u5de5\u5177\u680f\u3002<\/span><strong><span leaf=\"\">\u4f60\u53ea\u9700\u5728\u9875\u9762\u91cc\u624b\u52a8\u5b8c\u6210\u201c\u6dfb\u52a0\u4e00\u6761\u5f85\u529e \u2192 \u52fe\u9009\u5b8c\u6210 \u2192 \u5220\u9664\u8be5\u5f85\u529e\u201d<\/span><\/strong><span leaf=\"\">\uff0c\u53f3\u4fa7\u5c31\u4f1a\u540c\u6b65\u751f\u6210\u5e72\u51c0\u7684 Python \u6216 JavaScript \u4ee3\u7801\u3002\u901a\u8fc7\u5de5\u5177\u680f\u53f3\u4e0a\u89d2\u53ef\u4ee5\u5207\u6362\u76ee\u6807\u8bed\u8a00\uff08\u652f\u6301 JS\u3001TS\u3001Python\u3001Java\u3001.NET\uff09\uff0c\u751a\u81f3\u80fd\u6307\u5b9a\u751f\u6210\u7684\u6d4b\u8bd5\u6846\u67b6\u98ce\u683c\u3002\u5f55\u5236\u7ed3\u675f\u65f6\u70b9\u51fb \u201cGenerate code\u201d\uff0c\u4e00\u4efd\u7ed3\u6784\u5b8c\u6574\u7684\u6d4b\u8bd5\u6587\u4ef6\u5c31\u8bde\u751f\u4e86\u3002\u9664\u4e86\u5f55\u5236\u64cd\u4f5c\uff0ccodegen \u8fd8\u652f\u6301&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--device<\/span><\/code><span leaf=\"\">&nbsp;\u6307\u5b9a\u79fb\u52a8\u8bbe\u5907\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--viewport-size<\/span><\/code><span leaf=\"\">&nbsp;\u8bbe\u7f6e\u89c6\u53e3\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--browser<\/span><\/code><span leaf=\"\">&nbsp;\u9009\u62e9\u5185\u6838\uff0c\u65b9\u4fbf\u4f60\u4e00\u6b21\u4ea7\u51fa\u9002\u914d\u591a\u7aef\u7684\u811a\u672c\u9aa8\u67b6\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u8fd9\u91cc\u6709\u4e2a\u5b9e\u7528\u5c0f\u6280\u5de7\uff1acodegen \u751f\u6210\u7684\u9009\u62e9\u5668\u901a\u5e38\u4f1a\u4f18\u5148\u7528<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u8bed\u4e49\u5316\u3001\u7a33\u5b9a\u7684\u5b9a\u4f4d\u65b9\u5f0f<\/span><\/strong><span leaf=\"\">\uff08\u5982\u6587\u672c\u5339\u914d\u3001role \u89d2\u8272\uff09\uff0c\u800c\u4e0d\u662f\u8106\u5f31\u7684 XPath \u6216\u968f\u673a class\uff0c\u8fd9\u6bd4\u5f88\u591a\u4eba\u624b\u5199\u7684\u5b9a\u4f4d\u8868\u8fbe\u5f0f\u8981\u53ef\u9760\u5f97\u591a\u3002\u540c\u65f6\uff0c\u914d\u5408&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright codegen --save-storage=auth.json<\/span><\/code><span leaf=\"\">&nbsp;\u8fd8\u80fd\u5728\u5f55\u5236\u8fc7\u7a0b\u4e2d\u987a\u624b\u628a\u767b\u5f55\u6001\u5b58\u4e0b\u6765\uff0c\u540e\u7eed\u7528\u4f8b\u76f4\u63a5\u8bfb\u53d6\uff0c\u7701\u53bb\u91cd\u590d\u767b\u5f55\u3002\u5f53\u7136\uff0c\u5f55\u5236\u4ea7\u51fa\u7684\u4ee3\u7801\u66f4\u9002\u5408\u4f5c\u4e3a\u201c\u9aa8\u67b6\u201d\uff0c\u771f\u6b63\u4e0a\u751f\u4ea7\u8fd8\u9700\u8981\u6211\u4eec\u628a\u5b83\u6574\u7406\u6210\u89c4\u8303\u7684 Test Runner \u7528\u4f8b\u2014\u2014\u8fd9\u6b63\u662f\u4e0b\u4e00\u7ae0\u7684\u5185\u5bb9\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5f55\u5236\u65f6\u8fd8\u6709\u4e00\u4e2a\u9690\u85cf\u6280\u5de7\uff1acodegen \u652f\u6301&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--pause<\/span><\/code><span leaf=\"\">&nbsp;\u6682\u505c\u5f55\u5236\uff0c\u65b9\u4fbf\u4f60\u5728\u590d\u6742\u4ea4\u4e92\uff08\u5982\u62d6\u62fd\u3001\u6587\u4ef6\u4e0a\u4f20\uff09\u65f6\u624b\u52a8\u64cd\u4f5c\u540e\u518d\u7ee7\u7eed\uff1b\u4e5f\u53ef\u4ee5\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--output<\/span><\/code><span leaf=\"\">&nbsp;\u76f4\u63a5\u628a\u751f\u6210\u7684\u811a\u672c\u5199\u5165\u6307\u5b9a\u6587\u4ef6\uff0c\u7701\u53bb\u590d\u5236\u7c98\u8d34\u3002\u66f4\u8fdb\u4e00\u6b65\uff0ccodegen \u4f1a\u81ea\u52a8\u5ffd\u7565\u65e0\u5173\u70b9\u51fb\u3001\u5408\u5e76\u8fde\u7eed\u8f93\u5165\uff0c\u4ea7\u51fa\u7684\u811a\u672c\u6bd4\u7eaf\u624b\u6572\u66f4\u63a5\u8fd1\u6700\u4f73\u5b9e\u8df5\uff0c\u65b0\u624b\u5c24\u5176\u503c\u5f97\u4ece\u5b83\u5165\u624b\uff0c\u5efa\u7acb\u5bf9\u201c\u597d\u5b9a\u4f4d\u5668\u957f\u4ec0\u4e48\u6837\u201d\u7684\u76f4\u89c9\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u987a\u5e26\u63d0\u9192\u73af\u5883\u5c42\u9762\u7684\u4e24\u4e2a\u5751\uff1a\u4e00\u662f<\/span><strong><span leaf=\"\">\u7248\u672c\u4e00\u81f4\u6027<\/span><\/strong><span leaf=\"\">\uff0c\u52a1\u5fc5\u8ba9&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">@playwright\/test<\/span><\/code><span leaf=\"\">&nbsp;\u7684 npm \u7248\u672c\u4e0e&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">playwright install<\/span><\/code><span leaf=\"\">&nbsp;\u4e0b\u8f7d\u7684\u6d4f\u89c8\u5668\u7248\u672c\u5bf9\u9f50\uff0c\u8de8\u5927\u7248\u672c\u6df7\u7528\u5e38\u5bfc\u81f4\u534f\u8bae\u4e0d\u517c\u5bb9\uff1b\u4e8c\u662f<\/span><strong><span leaf=\"\">CI \u4e0a\u7684\u7cfb\u7edf\u4f9d\u8d56<\/span><\/strong><span leaf=\"\">\uff0cLinux \u955c\u50cf\u9ed8\u8ba4\u7f3a\u5b57\u4f53\u4e0e\u5e93\uff0c\u4e00\u5b9a\u8981\u5e26&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">install-deps<\/span><\/code><span leaf=\"\">\uff0c\u5426\u5219\u672c\u5730\u7eff\u3001\u4e0a\u7ebf\u5d29\u3002\u628a\u8fd9\u4e24\u70b9\u5199\u8fdb\u56e2\u961f\u7684\u300a\u73af\u5883\u642d\u5efa Checklist\u300b\uff0c\u80fd\u5c11\u8d70\u5f88\u591a\u5f2f\u8def\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5173\u4e8e\u5f55\u5236\u4ea7\u7269\u7684\u540e\u7eed\u5904\u7406\uff0c\u5efa\u8bae\u628a\u5b83\u5f53\u4f5c\u201c\u8349\u7a3f\u201d\u800c\u975e\u201c\u6210\u54c1\u201d\uff1a\u5148\u8dd1\u901a\uff0c\u518d\u8865\u65ad\u8a00\u3001\u62bd Page Object\u3001\u52a0\u7a33\u5b9a\u7684 testid\u3002\u5f88\u591a\u56e2\u961f\u8bef\u4ee5\u4e3a codegen \u76f4\u63a5\u80fd\u4e0a\u7ebf\uff0c\u7ed3\u679c\u5f55\u4e86\u4e00\u5806 brittle \u7684\u70b9\u51fb\u5e8f\u5217\u3002\u6b63\u786e\u59ff\u52bf\u662f\u201c\u5f55\u5236\u6253\u5e95\u3001\u624b\u5199\u63d0\u8d28\u201d\u2014\u2014\u7528\u5f55\u5236\u5feb\u901f\u8986\u76d6\u4e3b\u8def\u5f84\uff0c\u518d\u7528\u624b\u5199\u7528\u4f8b\u5b88\u4f4f\u8fb9\u754c\u4e0e\u5f02\u5e38\u573a\u666f\uff0c\u4e24\u8005\u7ed3\u5408\u6548\u7387\u6700\u9ad8\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u8bf4\u5230\u5e95\uff0ccodegen \u964d\u4f4e\u7684\u662f\u201c\u8d77\u6b65\u95e8\u69db\u201d\uff0c\u800c\u4e0d\u662f\u201c\u601d\u8003\u95e8\u69db\u201d\u3002\u5b83\u5e2e\u4f60\u628a\u91cd\u590d\u64cd\u4f5c\u53d8\u6210\u4ee3\u7801\uff0c\u4f46\u201c\u8be5\u6d4b\u4ec0\u4e48\u3001\u600e\u4e48\u65ad\u8a00\u3001\u5982\u4f55\u7ec4\u7ec7\u201d\uff0c\u4ecd\u8981\u9760\u4f60\u5bf9\u4e1a\u52a1\u7684\u7406\u89e3\u3002\u6240\u4ee5\u522b\u795e\u5316\u5f55\u5236\uff0c\u4e5f\u522b\u8f7b\u89c6\u5b83\u2014\u2014\u5b83\u662f\u8ba9\u56e2\u961f\u5feb\u901f\u5efa\u7acb\u4fe1\u5fc3\u3001\u5feb\u901f\u62ff\u5230\u6b63\u53cd\u9988\u7684\u5229\u5668\u3002\u5f88\u591a\u540c\u4e8b\u6b63\u662f\u88ab\u7b2c\u4e00\u6b21\u5f55\u5236\u5c31\u8dd1\u901a\u7684\u5feb\u611f\u201c\u79cd\u8349\u201d\uff0c\u624d\u613f\u610f\u7ee7\u7eed\u6df1\u5165\u5199\u66f4\u89c4\u8303\u7684\u7528\u4f8b\u3002<\/span><\/p>\n<section style=\"text-align: center;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\ud83d\udcf7 \u56fe2\uff1acodegen \u5f55\u5236\u754c\u9762\uff08\u6df1\u8272\u4e3b\u9898\u6a21\u62df\uff09<\/span><\/span><\/section>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000470\" data-s=\"300,640\" data-type=\"png\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/BWmfcibGhS1KnWqeLqtBjibT7Rs7nxmZia1BvhwG4RLcmF8EAJOSLRtYvmcyXVjUWo8KrbKAF08EWEar17mNOSKt4DdVPhFET4vj9gfGPRVSXI\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<section style=\"text-align: left;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><br  \/><\/span><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 18px;color: rgb(26, 26, 46);border-left: 4px solid rgb(21, 101, 192);padding-left: 12px;margin: 36px 0px 16px;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u4e09\u3001Playwright Test Runner\uff1a\u5feb\u901f\u4e0a\u624b\u4e13\u4e1a\u6d4b\u8bd5<\/span><\/h2>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">codegen \u5e2e\u4f60\u8fc8\u51fa\u7b2c\u4e00\u6b65\uff0c\u4f46\u771f\u6b63\u8ba9\u6d4b\u8bd5\u53ef\u7ef4\u62a4\u3001\u53ef\u6269\u5c55\u7684\uff0c\u662f\u5b98\u65b9\u81ea\u5e26\u7684&nbsp;<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">Playwright Test Runner<\/span><\/strong><span leaf=\"\">\u3002\u5b83\u4e0d\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6267\u884c\u5668\uff0c\u800c\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u6d4b\u8bd5\u6846\u67b6\uff1a\u81ea\u5e26\u65ad\u8a00\u5e93\u3001\u5e76\u884c\u6267\u884c\u3001\u91cd\u8bd5\u673a\u5236\u3001\u5185\u7f6e\u62a5\u544a\uff0c\u751a\u81f3\u8fd8\u96c6\u6210\u4e86 trace\u3002\u4e00\u4e2a\u5178\u578b\u9879\u76ee\u957f\u8fd9\u6837\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"perl\"><code><span leaf=\"\"><span class=\"code-snippet__keyword\">my<\/span>-project\/ \u251c\u2500\u2500 playwright.config.ts&nbsp;<span class=\"code-snippet__comment\"># \u5168\u5c40\u914d\u7f6e \u251c\u2500\u2500 tests\/ \u2502 \u251c\u2500\u2500 search.spec.ts # \u641c\u7d22\u529f\u80fd\u7528\u4f8b \u2502 \u2514\u2500\u2500 cart.spec.ts # \u8d2d\u7269\u8f66\u7528\u4f8b \u2514\u2500\u2500 package.json<\/span><\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: left;text-indent: 2em;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u914d\u7f6e\u6587\u4ef6&nbsp;<\/span><\/span><code style=\"color: rgb(44, 44, 44);font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">playwright.config.ts<\/span><\/code><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span leaf=\"\">&nbsp;\u662f\u6838\u5fc3\u3002\u4f60\u5728\u8fd9\u91cc\u96c6\u4e2d\u5b9a\u4e49\u8981\u8dd1\u54ea\u4e9b\u6d4f\u89c8\u5668\u3001\u662f\u5426\u65e0\u5934\u3001\u89c6\u53e3\u5927\u5c0f\u3001\u57fa\u7840\u5730\u5740\u7b49\u3002<\/span><\/span><strong style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;color: rgb(21, 101, 192);\"><span leaf=\"\">\u6240\u6709\u91cd\u590d\u7684\u914d\u7f6e\u90fd\u6536\u53e3\u5728\u4e00\u5904<\/span><\/strong><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span leaf=\"\">\uff0c\u7528\u4f8b\u6587\u4ef6\u91cc\u5c31\u53ea\u5269\u7eaf\u4e1a\u52a1\u903b\u8f91\u3002\u4e0b\u9762\u8fd9\u4efd\u914d\u7f6e\u540c\u65f6\u58f0\u660e\u4e86\u4e09\u4e2a\u6d4f\u89c8\u5668\u9879\u76ee\uff0c\u5e76\u6253\u5f00\u4e86\u5931\u8d25\u91cd\u8bd5\u5f55 trace \u7684\u5f00\u5173\uff1a<\/span><\/span><\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"php\"><code><span leaf=\"\">import { defineConfig, devices }&nbsp;<span class=\"code-snippet__keyword\">from<\/span>&nbsp;<span class=\"code-snippet__string\">'@playwright\/test'<\/span>;<\/span><\/code><code><span leaf=\"\">export&nbsp;<span class=\"code-snippet__keyword\">default<\/span>&nbsp;<span class=\"code-snippet__title\">defineConfig<\/span>({<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">testDir<\/span>:&nbsp;<span class=\"code-snippet__string\">'.\/tests'<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">use<\/span>: {<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">baseURL<\/span>:&nbsp;<span class=\"code-snippet__string\">'https:\/\/demo.playwright.dev'<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">headless<\/span>:&nbsp;<span class=\"code-snippet__literal\">true<\/span>, \/\/ \u65e0\u5934\u6a21\u5f0f\uff0cCI \u5fc5\u5f00<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">viewport<\/span>: {&nbsp;<span class=\"code-snippet__attr\">width<\/span>:&nbsp;<span class=\"code-snippet__number\">1280<\/span>,&nbsp;<span class=\"code-snippet__attr\">height<\/span>:&nbsp;<span class=\"code-snippet__number\">720<\/span>&nbsp;},<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">trace<\/span>:&nbsp;<span class=\"code-snippet__string\">'on-first-retry'<\/span>, \/\/ \u5931\u8d25\u91cd\u8bd5\u65f6\u81ea\u52a8\u5f55 trace<\/span><\/code><code><span leaf=\"\">&nbsp; },<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__attr\">projects<\/span>: [<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; {<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">name<\/span>:&nbsp;<span class=\"code-snippet__string\">'chromium'<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">use<\/span>: { ...devices[<span class=\"code-snippet__string\">'Desktop Chrome'<\/span>] },<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; },<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; {<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">name<\/span>:&nbsp;<span class=\"code-snippet__string\">'firefox'<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">use<\/span>: { ...devices[<span class=\"code-snippet__string\">'Desktop Firefox'<\/span>] },<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; },<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; {<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">name<\/span>:&nbsp;<span class=\"code-snippet__string\">'webkit'<\/span>,<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__attr\">use<\/span>: { ...devices[<span class=\"code-snippet__string\">'Desktop Safari'<\/span>] },<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; },<\/span><\/code><code><span leaf=\"\">&nbsp; ],<\/span><\/code><code><span leaf=\"\">});<\/span><\/code><\/pre>\n<\/section>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u63a5\u4e0b\u6765\u662f Playwright \u7684<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u57fa\u7840 API \u56db\u4ef6\u5957<\/span><\/strong><span leaf=\"\">\uff0c\u8bb0\u4f4f\u8fd9\u51e0\u4e2a\u5c31\u591f\u8986\u76d6 80% \u573a\u666f\u3002\u9700\u8981\u5f3a\u8c03\u7684\u662f\uff0c<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">locator<\/span><\/code><span leaf=\"\">&nbsp;\u8fd4\u56de\u7684\u662f\u4e00\u4e2a\u201c\u60f0\u6027\u5b9a\u4f4d\u5668\u201d\uff0c\u5b83\u4e0d\u4f1a\u7acb\u523b\u53bb\u9875\u9762\u627e\u5143\u7d20\uff0c\u800c\u662f\u5728\u4f60\u6267\u884c\u64cd\u4f5c\u6216\u65ad\u8a00\u65f6\u624d\u89e3\u6790\uff0c\u5e76\u81ea\u52a8\u7b49\u5f85\u5143\u7d20\u5c31\u4f4d\uff0c\u8fd9\u6b63\u662f\u5b83\u6bd4 Selenium&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">findElement<\/span><\/code><span leaf=\"\">&nbsp;\u7a33\u7684\u6839\u6e90\uff1a<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 8px 0px 0px;\"><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;font-weight: bold;\">\u2460<\/span>&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.goto(url)<\/span><\/code><span leaf=\"\">\u2014\u2014\u5bfc\u822a\u5230\u76ee\u6807\u9875\u9762\uff0c\u652f\u6301\u76f8\u5bf9\u8def\u5f84\uff08\u914d\u5408 baseURL\uff09\uff1b<\/span><br  \/><span leaf=\"\" style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><br  \/><\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 8px 0px 0px;\"><span leaf=\"\" style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span textstyle=\"\" style=\"color: #d92142;font-weight: bold;\">\u2461<\/span><\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.locator(selector)<\/span><\/code><span leaf=\"\">\u2014\u2014\u5b9a\u4f4d\u5143\u7d20\uff0c\u9009\u62e9\u5668\u652f\u6301 CSS\u3001\u6587\u672c\u3001XPath\uff0c\u8fd8\u652f\u6301<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">getByRole<\/span><\/code><span leaf=\"\">\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">getByText<\/span><\/code><span leaf=\"\">\u7b49\u8bed\u4e49\u5316\u65b9\u5f0f\uff1b<\/span><br  \/><span leaf=\"\" style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><br  \/><\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 8px 0px 0px;\"><span leaf=\"\" style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span textstyle=\"\" style=\"color: #d92142;font-weight: bold;\">\u2462<\/span><\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.fill()<\/span><\/code><span leaf=\"\">\/<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.click()<\/span><\/code><span leaf=\"\">\/<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.check()<\/span><\/code><span leaf=\"\">\u2014\u2014\u8f93\u5165\u3001\u70b9\u51fb\u3001\u52fe\u9009\uff1b<\/span><br  \/><span leaf=\"\" style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><br  \/><\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 8px 0px 0px;\"><span leaf=\"\" style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;\"><span textstyle=\"\" style=\"color: #d92142;font-weight: bold;\">\u2463<\/span><\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">expect(locator).toHaveText()<\/span><\/code><span leaf=\"\">\/<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">toBeVisible()<\/span><\/code><span leaf=\"\">\/<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">toBeChecked()<\/span><\/code><span leaf=\"\">\u2014\u2014\u65ad\u8a00\u7ed3\u679c\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 8px 0px 0px;\"><span leaf=\"\"><br  \/><\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u9664\u4e86\u8fd9\u4e9b\uff0cTest Runner \u8fd8\u63d0\u4f9b&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">beforeEach \/ afterEach<\/span><\/code><span leaf=\"\">&nbsp;\u94a9\u5b50\u7528\u4e8e\u51c6\u5907\u4e0e\u6e05\u7406\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">test.describe<\/span><\/code><span leaf=\"\">&nbsp;\u7528\u4e8e\u7528\u4f8b\u5206\u7ec4\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">test.step<\/span><\/code><span leaf=\"\">&nbsp;\u7528\u4e8e\u628a\u957f\u7528\u4f8b\u62c6\u6210\u6709\u5c42\u6b21\u7684\u6b65\u9aa4\uff08\u5728\u62a5\u544a\u4e2d\u6e05\u6670\u53ef\u89c1\uff09\u3001\u4ee5\u53ca&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">fixtures<\/span><\/code><span leaf=\"\">&nbsp;\u8fd9\u79cd\u5f3a\u5927\u7684\u4f9d\u8d56\u6ce8\u5165\u673a\u5236\u3002\u4e0b\u9762\u7528\u4e00\u4e2a\u201c\u641c\u7d22\u529f\u80fd\u201d\u7684\u5b9e\u6218\u7528\u4f8b\u628a\u57fa\u7840 API \u90fd\u4e32\u8d77\u6765\uff1a\u6253\u5f00\u9996\u9875 \u2192 \u5728\u641c\u7d22\u6846\u8f93\u5165\u5173\u952e\u8bcd \u2192 \u70b9\u51fb\u641c\u7d22 \u2192 \u9a8c\u8bc1\u7ed3\u679c\u5217\u8868\u51fa\u73b0\u5339\u914d\u9879\u3002<\/span><strong><span leaf=\"\">\u6ce8\u610f\uff1a\u6211\u4eec\u6ca1\u6709\u5199\u4efb\u4f55\u663e\u5f0f\u7b49\u5f85<\/span><\/strong><span leaf=\"\">\uff0c\u56e0\u4e3a&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">expect<\/span><\/code><span leaf=\"\">&nbsp;\u4f1a\u81ea\u52a8\u8f6e\u8be2\u76f4\u5230\u6ee1\u8db3\u6761\u4ef6\uff08\u9ed8\u8ba4\u8d85\u65f6 5 \u79d2\uff09\uff0c\u8fd9\u5c31\u662f\u81ea\u52a8\u7b49\u5f85\u7684\u5a01\u529b\u3002<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;{ test, expect }&nbsp;<span class=\"code-snippet__keyword\">from<\/span>&nbsp;<span class=\"code-snippet__string\">'@playwright\/test'<\/span>;<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__title\">test<\/span>(<span class=\"code-snippet__string\">'\u641c\u7d22\u529f\u80fd\u8fd4\u56de\u6b63\u786e\u7ed3\u679c'<\/span>,&nbsp;<span class=\"code-snippet__title\">async<\/span>&nbsp;({ page }) =&gt; {<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;page.<span class=\"code-snippet__title\">goto<\/span>(<span class=\"code-snippet__string\">'\/'<\/span>);<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;page.<span class=\"code-snippet__title\">locator<\/span>(<span class=\"code-snippet__string\">'#search-input'<\/span>).<span class=\"code-snippet__title\">fill<\/span>(<span class=\"code-snippet__string\">'Playwright'<\/span>);<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;page.<span class=\"code-snippet__title\">getByRole<\/span>(<span class=\"code-snippet__string\">'button'<\/span>, {&nbsp;<span class=\"code-snippet__attr\">name<\/span>:&nbsp;<span class=\"code-snippet__string\">'\u641c\u7d22'<\/span>&nbsp;}).<span class=\"code-snippet__title\">click<\/span>();&nbsp;<span class=\"code-snippet__comment\">\/\/ \u81ea\u52a8\u7b49\u5f85\uff1a\u76f4\u5230\u7ed3\u679c\u51fa\u73b0<\/span><\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;<span class=\"code-snippet__title\">expect<\/span>(page.<span class=\"code-snippet__title\">locator<\/span>(<span class=\"code-snippet__string\">'.result-item'<\/span>).<span class=\"code-snippet__title\">first<\/span>()).<span class=\"code-snippet__title\">toHaveText<\/span>(<span class=\"code-snippet__regexp\">\/Playwright\/<\/span>);<\/span><\/code><code><span leaf=\"\">});<\/span><\/code><\/pre>\n<\/section>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u5199\u5b8c\u4fdd\u5b58\u4e3a&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">tests\/search.spec.ts<\/span><\/code><span leaf=\"\">\uff0c\u5728\u7ec8\u7aef\u6572&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright test<\/span><\/code><span leaf=\"\">\uff0c\u4f60\u4f1a\u770b\u5230\u6d4b\u8bd5\u5728\u9ed8\u8ba4\u6d4f\u89c8\u5668\u4e2d\u4e00\u6c14\u5475\u6210\u8dd1\u5b8c\uff0c\u5e76\u9644\u5e26\u4e00\u4efd HTML \u62a5\u544a\u94fe\u63a5\u3002\u60f3\u7528\u6709\u5934\u6a21\u5f0f\u770b\u6d4f\u89c8\u5668\u5b9e\u9645\u64cd\u4f5c\uff0c\u52a0&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--headed<\/span><\/code><span leaf=\"\">\uff1b\u60f3\u5355\u6b65\u8c03\u8bd5\uff0c\u52a0&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--debug<\/span><\/code><span leaf=\"\">&nbsp;\u4f1a\u6253\u5f00 Inspector \u8ba9\u4f60\u9010\u6b65\u6267\u884c\u3002\u8fd9\u4e00\u5957\u201c\u914d\u7f6e + \u5b9a\u4f4d + \u64cd\u4f5c + \u65ad\u8a00\u201d\u7684\u8303\u5f0f\uff0c\u540e\u9762\u6240\u6709\u7528\u4f8b\u90fd\u4f9d\u6b64\u5c55\u5f00\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u518d\u8865\u5145 Test Runner \u7684\u4e24\u4e2a\u6740\u624b\u950f\u3002\u5176\u4e00\u662f&nbsp;<\/span><strong><span leaf=\"\">fixtures<\/span><\/strong><span leaf=\"\">\uff1a\u5b83\u50cf\u4f9d\u8d56\u6ce8\u5165\u4e00\u6837\uff0c\u8ba9\u4f60\u7528\u51fd\u6570\u58f0\u660e\u201c\u524d\u7f6e\u6761\u4ef6\u201d\uff0c\u6bd4\u5982\u4e00\u4e2a\u767b\u5f55\u6001 fixture \u88ab\u591a\u4e2a\u7528\u4f8b\u590d\u7528\uff0cPlaywright \u4f1a\u81ea\u52a8\u7ba1\u7406\u5176\u751f\u547d\u5468\u671f\uff0c\u65e0\u9700\u5230\u5904\u5199\u91cd\u590d\u7684 beforeEach\u3002\u5176\u4e8c\u662f&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">test.step()<\/span><\/code><span leaf=\"\">\uff1a\u628a\u957f\u7528\u4f8b\u62c6\u6210\u201c\u6253\u5f00\u9875\u9762\u2192\u767b\u5f55\u2192\u4e0b\u5355\u201d\u8fd9\u6837\u7684\u6709\u547d\u540d\u6b65\u9aa4\uff0c\u62a5\u544a\u91cc\u5c42\u7ea7\u6e05\u6670\uff0c\u51fa\u95ee\u9898\u65f6\u4e00\u773c\u5c31\u80fd\u770b\u5230\u5361\u5728\u54ea\u4e00\u6b65\u3002\u8fd9\u4e24\u4e2a\u7279\u6027\u662f\u5927\u578b\u5957\u4ef6\u4fdd\u6301\u53ef\u8bfb\u3001\u53ef\u7ef4\u62a4\u7684\u5173\u952e\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u65ad\u8a00\u5199\u6cd5\u7684\u7ec6\u8282\u4e5f\u503c\u5f97\u5c55\u5f00\uff1a<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">expect<\/span><\/code><span leaf=\"\">&nbsp;\u4e0d\u4ec5\u652f\u6301&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">toHaveText<\/span><\/code><span leaf=\"\">\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">toBeVisible<\/span><\/code><span leaf=\"\">\uff0c\u8fd8\u652f\u6301&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">toContainText<\/span><\/code><span leaf=\"\">\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">toHaveAttribute<\/span><\/code><span leaf=\"\">\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">toHaveCount<\/span><\/code><span leaf=\"\">&nbsp;\u7b49\u5341\u4f59\u79cd\u8bed\u4e49\u5316\u5339\u914d\u5668\uff1b\u5bf9\u4e8e\u5f02\u6b65\u72b6\u6001\uff0c\u53ef\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">expect.poll()<\/span><\/code><span leaf=\"\">&nbsp;\u8f6e\u8be2\u81ea\u5b9a\u4e49\u51fd\u6570\u3002\u5f3a\u70c8\u5efa\u8bae\u628a\u65ad\u8a00\u5199\u6210\u201c\u63cf\u8ff0\u4e1a\u52a1\u610f\u56fe\u201d\u7684\u5f62\u5f0f\uff0c\u800c\u4e0d\u662f\u201c\u6bd4\u5bf9 DOM \u7ec6\u8282\u201d\uff0c\u8fd9\u6837\u7528\u4f8b\u5373\u4f7f\u9875\u9762\u91cd\u6784\u4e5f\u66f4\u6613\u5b58\u6d3b\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u76ee\u5f55\u7ec4\u7ec7\u4e5f\u6709\u8bb2\u7a76\uff1a\u7528\u4f8b\u6309\u4e1a\u52a1\u6a21\u5757\u5206\u6587\u4ef6\uff08search.spec.ts\u3001cart.spec.ts\uff09\uff0c\u516c\u5171\u903b\u8f91\u6536\u8fdb fixtures \u4e0e helpers\uff0c\u914d\u7f6e\u96c6\u4e2d\u5230 playwright.config.ts\u3002\u5f53\u56e2\u961f\u8d85\u8fc7 3 \u4eba\uff0c\u518d\u5f15\u5165\u73af\u5883\u53d8\u91cf\u533a\u5206\u672c\u5730\u4e0e CI \u884c\u4e3a\u3002\u6e05\u6670\u7684\u7ed3\u6784\u80fd\u8ba9\u65b0\u4eba\u5728\u5341\u5206\u949f\u5185\u770b\u61c2\u201c\u4e00\u4e2a\u7528\u4f8b\u4ece\u54ea\u6765\u3001\u5230\u54ea\u53bb\u201d\uff0c\u8fd9\u662f\u534f\u4f5c\u89c4\u6a21\u5316\u7684\u524d\u63d0\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u65ad\u8a00\u7684\u201c\u8f6f\u786c\u201d\u4e5f\u503c\u5f97\u4f53\u4f1a\uff1aPlaywright \u9ed8\u8ba4\u8d85\u65f6 5 \u79d2\u3001\u4e14\u4f1a\u6301\u7eed\u8f6e\u8be2\u5230\u6ee1\u8db3\u4e3a\u6b62\uff0c\u6240\u4ee5\u4f60\u51e0\u4e4e\u4e0d\u7528\u5199\u7b49\u5f85\u3002\u4f46\u9047\u5230\u201c\u5143\u7d20\u5148\u51fa\u73b0\u53c8\u88ab\u66ff\u6362\u201d\u7684\u7ade\u6001\uff08\u5e38\u89c1\u4e8e\u9aa8\u67b6\u5c4f\uff09\uff0c\u53ef\u4ee5\u4e34\u65f6\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">expect(locator).toBeVisible({ timeout: 10000 })<\/span><\/code><span leaf=\"\">&nbsp;\u62c9\u957f\uff0c\u6216\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">toHaveCount<\/span><\/code><span leaf=\"\">&nbsp;\u7b49\u96c6\u5408\u65ad\u8a00\u53d6\u4ee3\u5355\u5143\u7d20\u65ad\u8a00\uff0c\u4ece\u6839\u4e0a\u907f\u5f00\u65f6\u5e8f\u9677\u9631\u3002\u628a\u201c\u7b49\u5f85\u201d\u4ea4\u7ed9\u6846\u67b6\uff0c\u662f\u5199\u51fa\u7a33\u5b9a\u7528\u4f8b\u7684\u7b2c\u4e00\u539f\u5219\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u6700\u540e\u7ed9\u65b0\u4eba\u4e00\u53e5\u5fe0\u544a\uff1a\u522b\u8ffd\u6c42\u201c\u4e00\u6761\u7528\u4f8b\u8986\u76d6\u6240\u6709\u5206\u652f\u201d\uff0c\u90a3\u6837\u5b9a\u4f4d\u5668\u4f1a\u53d8\u590d\u6742\u3001\u5931\u8d25\u4e5f\u96be\u5b9a\u4f4d\u3002\u5b81\u53ef\u62c6\u6210\u591a\u6761\u5c0f\u800c\u4e13\u7684\u7528\u4f8b\uff0c\u6bcf\u6761\u53ea\u9a8c\u8bc1\u4e00\u4e2a\u660e\u786e\u610f\u56fe\u3002\u53ef\u8bfb\u3001\u53ef\u5b9a\u4f4d\u3001\u53ef\u72ec\u7acb\uff0c\u6bd4\u201c\u770b\u8d77\u6765\u5f88\u7701\u201d\u91cd\u8981\u5f97\u591a\u3002\u7528\u4f8b\u662f\u5199\u7ed9\u4eba\u770b\u7684\uff0c\u673a\u5668\u53ea\u662f\u987a\u5e26\u6267\u884c\u3002<\/span><\/p>\n<section style=\"text-align: center;text-indent: 2em;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\ud83d\udcf7 \u56fe3\uff1aPlaywright Test \u4ee3\u7801\u793a\u4f8b\uff08\u7ec8\u7aef\u9ad8\u4eae\u98ce\u683c\uff09<\/span><\/span><\/span><\/span><\/section>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000471\" data-s=\"300,640\" data-type=\"png\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/mmbiz_png\/BWmfcibGhS1KIWlylQVmQup5wtW5uqHURFI9fzdtOW4q4MuIMuCholvuXZ2H5CQGX9pCtn4EZeyV2YPjgYZ6LGicdcMLmylDQZBRCW5Nnl5Rs\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<section style=\"text-align: left;text-indent: 2em;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><br  \/><\/span><\/span><\/span><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 18px;color: rgb(26, 26, 46);border-left: 4px solid rgb(21, 101, 192);padding-left: 12px;margin: 36px 0px 16px;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u56db\u3001\u8de8\u6d4f\u89c8\u5668\u6267\u884c\uff1a\u4e00\u4efd\u811a\u672c\u8dd1\u904d\u4e09\u5927\u5185\u6838<\/span><\/h2>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u524d\u9762\u914d\u7f6e\u91cc\u6211\u4eec\u5df2\u7ecf\u5728&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">projects<\/span><\/code><span leaf=\"\">&nbsp;\u91cc\u58f0\u660e\u4e86 chromium\u3001firefox\u3001webkit \u4e09\u4e2a\u9879\u76ee\u3002\u5f53\u6267\u884c&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright test<\/span><\/code><span leaf=\"\">&nbsp;\u65f6\uff0c<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u540c\u4e00\u4efd\u7528\u4f8b\u4f1a\u81ea\u52a8\u5728\u4e09\u79cd\u5185\u6838\u4e0a\u5404\u8dd1\u4e00\u904d<\/span><\/strong><span leaf=\"\">\u3002\u5982\u679c\u4f60\u53ea\u60f3\u9488\u5bf9\u67d0\u4e2a\u6d4f\u89c8\u5668\uff0c\u52a0\u4e2a\u53c2\u6570\u5373\u53ef\uff1a<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--project=firefox<\/span><\/code><span leaf=\"\">\u3002\u8fd9\u5c31\u662f\u201c\u4e00\u5957\u811a\u672c\u3001\u4e09\u7aef\u8986\u76d6\u201d\u7684\u7cbe\u9ad3\u3002Playwright \u8fd8\u652f\u6301\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--grep<\/span><\/code><span leaf=\"\">&nbsp;\u6309\u7528\u4f8b\u6807\u9898\u8fc7\u6ee4\u3001\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--workers<\/span><\/code><span leaf=\"\">&nbsp;\u63a7\u5236\u5e76\u53d1\uff0c\u65e5\u5e38\u6392\u67e5\u975e\u5e38\u987a\u624b\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u4e3a\u4e86\u63d0\u901f\uff0cPlaywright \u9ed8\u8ba4\u5f00\u542f<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u5e76\u884c\u6267\u884c<\/span><\/strong><span leaf=\"\">\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">workers<\/span><\/code><span leaf=\"\">&nbsp;\u53c2\u6570\u63a7\u5236\u5e76\u53d1\u6570\uff0c\u6bd4\u5982&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">workers: 4<\/span><\/code><span leaf=\"\">&nbsp;\u8868\u793a\u6700\u591a 4 \u4e2a worker \u540c\u65f6\u8dd1\u3002\u672c\u5730\u5f00\u53d1\u5efa\u8bae\u8bbe\u5c0f\u4e00\u70b9\uff08\u5982 2\uff09\uff0cCI \u4e0a\u53ef\u4ee5\u62c9\u6ee1\u673a\u5668\u6838\u5fc3\u6570\u3002\u6bcf\u4e2a worker \u62e5\u6709\u72ec\u7acb\u7684\u6d4f\u89c8\u5668\u4e0a\u4e0b\u6587\uff08Browser Context\uff09\uff0c\u5929\u7136\u9694\u79bb Cookie\u3001\u7f13\u5b58\u548c localStorage\uff0c<\/span><strong><span leaf=\"\">\u7528\u4f8b\u4e4b\u95f4\u4e92\u4e0d\u6c61\u67d3\uff0c\u8fd9\u4e5f\u662f Playwright \u7a33\u5b9a\u6027\u8fdc\u9ad8\u4e8e Selenium \u7684\u5173\u952e\u8bbe\u8ba1<\/span><\/strong><span leaf=\"\">\u3002\u66f4\u8fdb\u4e00\u6b65\uff0c\u4f60\u8fd8\u80fd\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--shard=1\/3<\/span><\/code><span leaf=\"\">&nbsp;\u628a\u7528\u4f8b\u96c6\u5207\u6210\u591a\u7247\u5206\u53d1\u7ed9\u4e0d\u540c\u673a\u5668\uff0c\u505a\u8d85\u5927\u89c4\u6a21\u5206\u7247\uff0c\u628a\u534a\u5c0f\u65f6\u7684\u56de\u5f52\u538b\u5230\u51e0\u5206\u949f\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5728 CI \u4e2d\u66f4\u8fdb\u9636\u7684\u505a\u6cd5\u662f\u201c\u77e9\u9635\u7b56\u7565\u201d\uff1a\u628a\u4e0d\u540c\u6d4f\u89c8\u5668\u62c6\u5230\u4e0d\u540c\u7684\u6d41\u6c34\u7ebf\u4efb\u52a1\u91cc\u5e76\u884c\uff0c\u54ea\u4e2a\u6302\u4e86\u80fd\u7acb\u523b\u5b9a\u4f4d\uff0c\u8fd8\u80fd\u5355\u72ec\u91cd\u8bd5\u3002\u4f8b\u5982 GitHub Actions \u91cc\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">matrix: { browser: [chromium, firefox, webkit] }<\/span><\/code><span leaf=\"\">\uff0c\u4e09\u4e2a\u6d4f\u89c8\u5668\u540c\u65f6\u5f00\u8dd1\uff0c\u6574\u4f53\u65f6\u95f4\u7ea6\u7b49\u4e8e\u5355\u4e2a\u6d4f\u89c8\u5668\u8017\u65f6\u3002\u6ce8\u610f\u4e00\u4e2a\u5de5\u7a0b\u7ec6\u8282\uff1aWebKit \u5728 Linux \u4e0a\u9700\u8981\u7cfb\u7edf\u88c5\u597d\u5fc5\u8981\u7684\u4f9d\u8d56\u5e93\uff0c\u5426\u5219\u4f1a\u542f\u52a8\u5931\u8d25\uff0cCI \u955c\u50cf\u52a1\u5fc5\u5305\u542b&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">playwright install-deps webkit<\/span><\/code><span leaf=\"\">\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5f53\u7136\uff0c\u8de8\u6d4f\u89c8\u5668\u4e5f\u5e38\u9047\u5230&nbsp;<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">flaky test\uff08\u5076\u53d1\u5931\u8d25\uff09<\/span><\/strong><span leaf=\"\">\u3002\u6700\u5e38\u89c1\u7684\u539f\u56e0\u662f\u6d4f\u89c8\u5668\u6e32\u67d3\u6216\u7f51\u7edc\u65f6\u5e8f\u5dee\u5f02\u3002\u5904\u7406\u601d\u8def\u6709\u4e09\uff1a\u7b2c\u4e00\uff0c\u6c38\u8fdc\u4f18\u5148\u4fe1\u4efb\u81ea\u52a8\u7b49\u5f85\uff0c\u522b\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.waitForTimeout(3000)<\/span><\/code><span leaf=\"\">&nbsp;\u8fd9\u79cd\u201c\u76f2\u7b49\u201d\uff1b\u7b2c\u4e8c\uff0c\u7ed9\u4e0d\u7a33\u5b9a\u6b65\u9aa4\u5355\u72ec\u8bbe\u8d85\u65f6\uff0c\u5982&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">{ timeout: 10000 }<\/span><\/code><span leaf=\"\">\uff1b\u7b2c\u4e09\uff0c\u5584\u7528 Playwright \u5185\u7f6e\u7684<\/span><strong><span leaf=\"\">\u91cd\u8bd5\u673a\u5236<\/span><\/strong><span leaf=\"\">&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">retries: 2<\/span><\/code><span leaf=\"\">\uff0c\u5931\u8d25\u81ea\u52a8\u91cd\u8dd1\uff0c\u533a\u5206\u201c\u771f bug\u201d\u548c\u201c\u5076\u53d1\u6296\u52a8\u201d\u3002\u4e0b\u9762\u662f flaky \u5904\u7406\u7684\u63a8\u8350\u4f18\u5148\u7ea7\uff1a\u5148\u5b9a\u4f4d\u662f\u201c\u9009\u62e9\u5668\u4e0d\u7a33\u5b9a\u201d\u8fd8\u662f\u201c\u7b49\u5f85\u4e0d\u8db3\u201d\uff0c\u518d\u51b3\u5b9a\u6539\u7528\u66f4\u7a33\u7684\u5b9a\u4f4d\u5668\u8fd8\u662f\u5f00\u542f\u91cd\u8bd5\uff0c\u5207\u5fcc\u4e00\u4e0a\u6765\u5c31\u5168\u5c40\u52a0\u957f\u8d85\u65f6\u63a9\u76d6\u95ee\u9898\u3002\u4e0b\u9762\u8fd9\u5f20\u77e9\u9635\u80fd\u76f4\u89c2\u770b\u5230\u4e09\u7c7b\u7528\u4f8b\u5728\u4e09\u4e2a\u5185\u6838\u4e0a\u7684\u6267\u884c\u7ed3\u679c\u5206\u5e03\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u987a\u5e26\u4e00\u63d0\uff0c\u5f53\u7528\u4f8b\u89c4\u6a21\u5230\u51e0\u767e\u6761\u65f6\uff0c\u5355\u53f0\u673a\u5668\u4e32\u884c\u8dd1\u4f1a\u5f88\u6162\u3002\u6b64\u65f6\u53ef\u4ee5\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--shard=1\/4<\/span><\/code><span leaf=\"\">&nbsp;\u628a\u5168\u96c6\u5207\u6210 4 \u7247\uff0c\u5206\u53d1\u5230 4 \u53f0\u673a\u5668\u5e76\u884c\uff0c\u518d\u628a\u7ed3\u679c\u5408\u5e76\uff0c\u6574\u4f53\u8017\u65f6\u4ece\u51e0\u5341\u5206\u949f\u538b\u5230\u51e0\u5206\u949f\u3002\u5206\u7247\u4e0e\u77e9\u9635\uff08\u6309\u6d4f\u89c8\u5668\uff09\u662f\u6b63\u4ea4\u7684\u4e24\u5957\u5e76\u884c\u7ef4\u5ea6\uff0c\u7ec4\u5408\u4f7f\u7528\u80fd\u628a\u6d77\u91cf\u56de\u5f52\u538b\u5230\u6781\u81f4\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u53e6\u5916\uff0c\u4e0d\u540c\u6d4f\u89c8\u5668\u5bf9\u201c\u67d0\u529f\u80fd\u662f\u5426\u652f\u6301\u201d\u672c\u5c31\u4e0d\u540c\uff08\u6bd4\u5982\u67d0 CSS \u7279\u6027\u53ea\u5728 Safari \u7f3a\u5931\uff09\uff0c\u6b63\u786e\u505a\u6cd5\u4e0d\u662f\u8ba9\u7528\u4f8b\u786c\u8dd1\uff0c\u800c\u662f\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">test.skip()<\/span><\/code><span leaf=\"\">&nbsp;\u5728 webkit \u9879\u76ee\u4e0b\u6709\u610f\u8bc6\u5730\u8df3\u8fc7\uff0c\u5e76\u6ce8\u660e\u539f\u56e0\u3002\u8fd9\u6837\u65e2\u4fdd\u6301\u8986\u76d6\uff0c\u53c8\u4e0d\u88ab\u8bef\u62a5\u62d6\u57ae\u3002\u8bb0\u4f4f\uff1a<\/span><strong><span leaf=\"\">\u8de8\u6d4f\u89c8\u5668\u6d4b\u8bd5\u7684\u76ee\u6807\u662f\u628a\u201c\u771f\u5b9e\u5dee\u5f02\u201d\u66b4\u9732\u51fa\u6765\uff0c\u800c\u4e0d\u662f\u628a\u5dee\u5f02\u5f3a\u884c\u62b9\u5e73<\/span><\/strong><span leaf=\"\">\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u8bf4\u5230\u7a33\u5b9a\u6027\uff0c\u8fd8\u6709\u4e00\u4e2a\u7ecf\u9a8c\uff1a\u7ed9\u7528\u4f8b\u6253\u6807\u7b7e\uff08\u5982&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">test('xxx', { tag: ['@smoke'] })<\/span><\/code><span leaf=\"\">\uff09\uff0cCI \u91cc\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--grep @smoke<\/span><\/code><span leaf=\"\">&nbsp;\u5148\u8dd1\u6838\u5fc3\u94fe\u8def\uff0c\u5168\u91cf\u653e\u591c\u95f4\u3002\u8fd9\u6837\u767d\u5929\u7684\u53cd\u9988\u53c8\u5feb\u53c8\u51c6\uff0c\u4e0d\u4f1a\u56e0\u4e3a\u4e00\u6761\u8fb9\u7f18\u7528\u4f8b\u5076\u53d1\u5931\u8d25\u800c\u963b\u585e\u5408\u5e76\u3002\u8de8\u6d4f\u89c8\u5668\u4e0d\u662f\u201c\u8d8a\u591a\u8d8a\u597d\u201d\uff0c\u800c\u662f\u201c\u6838\u5fc3\u7a33\u3001\u8fb9\u7f18\u6e05\u201d\uff0c\u8282\u594f\u6bd4\u8986\u76d6\u5ea6\u66f4\u91cd\u8981\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u8fd8\u6709\u4e00\u4e2a\u5bb9\u6613\u5ffd\u7565\u7684\u70b9\uff1a\u5e76\u884c\u4e0d\u7b49\u4e8e\u65e0\u8111\u5806 worker\u3002worker \u6570\u8d85\u8fc7\u673a\u5668\u6838\u5fc3\u6216\u5185\u5b58\u4e0a\u9650\uff0c\u53cd\u800c\u4f1a\u56e0\u8d44\u6e90\u4e89\u62a2\u53d8\u6162\u751a\u81f3\u5185\u5b58\u6ea2\u51fa\u3002\u7ecf\u9a8c\u503c\u662f\u672c\u5730\u8bbe 2\u3001CI \u8bbe\u4e3a\u6838\u5fc3\u6570\u7684\u4e8c\u5206\u4e4b\u4e00\u5230\u4e00\u500d\uff0c\u518d\u6309\u5b9e\u9645\u8017\u65f6\u5fae\u8c03\u3002\u914d\u5408\u5206\u7247\uff0c\u627e\u5230\u4f60\u9879\u76ee\u7684\u6700\u4f18\u5e76\u884c\u5ea6\uff0c\u5f80\u5f80\u80fd\u628a\u56de\u5f52\u4ece\u201c\u559d\u676f\u5496\u5561\u7684\u5de5\u592b\u201d\u538b\u5230\u201c\u53d1\u6761\u6d88\u606f\u7684\u5de5\u592b\u201d\u3002<\/span><\/p>\n<figure style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 24px 0px;background: rgb(248, 250, 252);border: 1px solid rgb(226, 232, 240);border-radius: 10px;padding: 20px;text-align: center;\">\n<p><span leaf=\"\">\ud83d\udcf7 \u56fe4\uff1a\u591a\u6d4f\u89c8\u5668\u6267\u884c\u77e9\u9635\uff08\u7528\u4f8b \u00d7 \u5185\u6838\uff09<\/span><\/p>\n<table style=\"width: 480px;max-width: 480px;margin: 0px auto;border-collapse: collapse;font-size: 13px;\">\n<tbody>\n<tr style=\"background: rgb(21, 101, 192);color: rgb(255, 255, 255);\">\n<th style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;\">\u6d4b\u8bd5\u7528\u4f8b \uff3c \u5185\u6838<\/span><\/span><\/section>\n<\/th>\n<th style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;\">Chromium<\/span><\/span><\/section>\n<\/th>\n<th style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;\">Firefox<\/span><\/span><\/section>\n<\/th>\n<th style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);\">\n<section><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;\">WebKit<\/span><\/span><\/section>\n<\/th>\n<\/tr>\n<tr>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);text-align: left;\">\n<section><span leaf=\"\">\u9996\u9875\u52a0\u8f7d\u9a8c\u8bc1<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);font-weight: bold;\">\n<section><span leaf=\"\">\u2713 \u901a\u8fc7<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);font-weight: bold;\">\n<section><span leaf=\"\">\u2713 \u901a\u8fc7<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);font-weight: bold;\">\n<section><span leaf=\"\">\u2713 \u901a\u8fc7<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(241, 245, 249);\">\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);text-align: left;\">\n<section><span leaf=\"\">\u641c\u7d22\u529f\u80fd<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);font-weight: bold;\">\n<section><span leaf=\"\">\u2713 \u901a\u8fc7<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);font-weight: bold;\">\n<section><span leaf=\"\">\u2713 \u901a\u8fc7<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);color: rgb(220, 38, 38);font-weight: bold;\">\n<section><span leaf=\"\">\u2717 \u5931\u8d25<\/span><\/section>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);text-align: left;\">\n<section><span leaf=\"\">\u52a0\u5165\u8d2d\u7269\u8f66<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);font-weight: bold;\">\n<section><span leaf=\"\">\u2713 \u901a\u8fc7<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);font-weight: bold;\">\n<section><span leaf=\"\">\u2713 \u901a\u8fc7<\/span><\/section>\n<\/td>\n<td style=\"padding: 10px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);font-weight: bold;\">\n<section><span leaf=\"\">\u2713 \u901a\u8fc7<\/span><\/section>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"font-size: 11px;color: rgb(136, 136, 136);margin: 10px 0px 0px;\"><span leaf=\"\">\u63d0\u793a\uff1aWebKit \u641c\u7d22\u5931\u8d25\u591a\u4e3a Safari \u4e13\u5c5e CSS \u517c\u5bb9\u95ee\u9898\uff0c\u5e94\u5206\u79bb\u6d4f\u89c8\u5668\u7279\u5b9a\u65ad\u8a00\u3002<\/span><\/p>\n<\/figure>\n<section style=\"text-align: left;text-indent: 2em;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><br  \/><\/span><\/span><\/span><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 18px;color: rgb(26, 26, 46);border-left: 4px solid rgb(21, 101, 192);padding-left: 12px;margin: 36px 0px 16px;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u4e94\u3001\u62a5\u544a\u4e0e\u8c03\u8bd5\uff1atrace viewer \u8ba9\u95ee\u9898\u65e0\u5904\u85cf\u8eab<\/span><\/h2>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u6d4b\u8bd5\u8dd1\u5b8c\u4e86\uff0c\u53ef\u4e00\u65e6\u5931\u8d25\uff0c\u6700\u6015\u7684\u5c31\u662f\u201c\u53ea\u6709\u4e00\u53e5\u62a5\u9519\uff0c\u4e0d\u77e5\u9053\u5f53\u65f6\u9875\u9762\u957f\u5565\u6837\u201d\u3002Playwright \u5728\u53ef\u89c2\u6d4b\u6027\u4e0a\u505a\u4e86\u5927\u91cf\u6295\u5165\uff0c<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u622a\u56fe\u3001\u89c6\u9891\u3001Trace \u4e09\u4ef6\u5957<\/span><\/strong><span leaf=\"\">\u8ba9\u6392\u67e5\u6548\u7387\u76f4\u63a5\u8d77\u98de\u3002\u8fd9\u4e09\u7c7b\u4ea7\u7269\u53ef\u4ee5\u5728\u914d\u7f6e\u91cc\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">use<\/span><\/code><span leaf=\"\">&nbsp;\u7edf\u4e00\u5f00\u5173\uff0c\u4e5f\u652f\u6301&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">'on'<\/span><\/code><span leaf=\"\">\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">'off'<\/span><\/code><span leaf=\"\">\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">'on-first-retry'<\/span><\/code><span leaf=\"\">\u3001<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">'retain-on-failure'<\/span><\/code><span leaf=\"\">&nbsp;\u7b49\u7cbe\u7ec6\u7b56\u7565\uff0c\u5e73\u8861\u8bc1\u636e\u5b8c\u6574\u6027\u4e0e\u78c1\u76d8\u5360\u7528\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u7b2c\u4e00\u62db\u662f<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u622a\u56fe<\/span><\/strong><span leaf=\"\">\uff1a\u5728\u7528\u4f8b\u91cc\u968f\u65f6\u8c03\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">await page.screenshot({ path: 'shot.png' })<\/span><\/code><span leaf=\"\">\uff0c\u5931\u8d25\u65f6\u81ea\u52a8\u7559\u8bc1\uff1b\u52a0&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">fullPage: true<\/span><\/code><span leaf=\"\">&nbsp;\u8fd8\u80fd\u622a\u6574\u9875\u957f\u56fe\u3002\u7b2c\u4e8c\u62db\u662f<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u89c6\u9891\u5f55\u5236<\/span><\/strong><span leaf=\"\">\uff0c\u53ea\u9700\u5728\u914d\u7f6e\u91cc\u8bbe&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">use: { video: 'on-first-retry' }<\/span><\/code><span leaf=\"\">\uff0c\u53ea\u6709\u9996\u6b21\u5931\u8d25\u91cd\u8bd5\u65f6\u624d\u5f55\u89c6\u9891\uff0c\u517c\u987e\u8bc1\u636e\u4e0e\u6027\u80fd\uff1b\u89c6\u9891\u683c\u5f0f\u4e3a WebM\uff0c\u53ef\u76f4\u63a5\u5728\u62a5\u544a\u91cc\u70b9\u5f00\u56de\u653e\u3002\u7b2c\u4e09\u62db\u2014\u2014\u4e5f\u662f\u6211\u6700\u63a8\u8350\u7684\u2014\u2014\u662f&nbsp;<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">trace viewer<\/span><\/strong><span leaf=\"\">\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">Trace \u76f8\u5f53\u4e8e\u7ed9\u6d4b\u8bd5\u8fc7\u7a0b\u5f55\u4e86\u4e00\u6bb5\u201c\u5e26 DOM \u5feb\u7167\u7684\u7535\u5f71\u201d\u3002\u914d\u7f6e&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">trace: 'on-first-retry'<\/span><\/code><span leaf=\"\">&nbsp;\u540e\uff0c\u5931\u8d25\u7528\u4f8b\u4f1a\u751f\u6210&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">.trace<\/span><\/code><span leaf=\"\">&nbsp;\u6587\u4ef6\uff0c\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright show-trace trace.zip<\/span><\/code><span leaf=\"\">&nbsp;\u6253\u5f00\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u582a\u6bd4\u5f00\u53d1\u8005\u5de5\u5177\u7684\u754c\u9762\uff1a\u5de6\u4fa7\u662f<\/span><strong><span leaf=\"\">\u65f6\u95f4\u7ebf<\/span><\/strong><span leaf=\"\">\uff08\u6bcf\u4e00\u6b21\u70b9\u51fb\u3001\u5bfc\u822a\u3001\u7f51\u7edc\u8bf7\u6c42\u90fd\u6709\u65f6\u95f4\u6233\uff09\uff0c\u53f3\u4fa7\u80fd<\/span><strong><span leaf=\"\">\u9010\u5e27\u56de\u653e DOM \u5feb\u7167<\/span><\/strong><span leaf=\"\">\u3001\u67e5\u770b\u5f53\u65f6\u7684\u6837\u5f0f\u4e0e\u5c5e\u6027\uff0c\u4e0b\u65b9\u8fd8\u6709<\/span><strong><span leaf=\"\">\u7f51\u7edc\u8bf7\u6c42\u9762\u677f<\/span><\/strong><span leaf=\"\">\uff0c\u54ea\u4e2a\u63a5\u53e3 404\u3001\u54ea\u4e2a\u8d44\u6e90\u6162\u4e00\u76ee\u4e86\u7136\u3002\u4f60\u751a\u81f3\u53ef\u4ee5\u70b9\u51fb\u65f6\u95f4\u7ebf\u4e0a\u7684\u4efb\u610f\u4e00\u6b65\uff0c\u76f4\u63a5\u770b\u5230\u90a3\u4e00\u6b65\u524d\u540e\u7684\u9875\u9762\u622a\u56fe\u5bf9\u6bd4\uff0c\u5b9a\u4f4d\u201c\u9875\u9762\u7a81\u7136\u53d8\u7a7a\u767d\u201d\u8fd9\u7c7b\u95ee\u9898\u51e0\u4e4e\u662f\u79d2\u7ea7\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u6b64\u5916\uff0c\u76d1\u542c\u63a7\u5236\u53f0\u65e5\u5fd7\u80fd\u5e2e\u4f60\u6355\u6349\u524d\u7aef\u62a5\u9519\u3002\u4e00\u884c&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.on('console', msg =&gt; { ... })<\/span><\/code><span leaf=\"\">&nbsp;\u5c31\u80fd\u628a\u9875\u9762\u91cc\u7684&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">console.error<\/span><\/code><span leaf=\"\">&nbsp;\u6293\u51fa\u6765\u5e76\u65ad\u8a00\uff0c\u5f88\u591a\u95ee\u9898\u5728\u201c\u9875\u9762\u8fd8\u6ca1\u5d29\u201d\u7684\u65f6\u5019\u5c31\u88ab\u4f60\u63d0\u524d\u53d1\u73b0\u3002\u914d\u5408&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.on('pageerror', ...)<\/span><\/code><span leaf=\"\">&nbsp;\u8fd8\u80fd\u6355\u83b7\u672a\u5904\u7406\u7684 JS \u5f02\u5e38\u3002\u8bf4\u5230\u5e95\uff0c<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u597d\u7684\u8c03\u8bd5\u5de5\u5177\u4e0d\u662f\u9526\u4e0a\u6dfb\u82b1\uff0c\u800c\u662f\u80fd\u76f4\u63a5\u51b3\u5b9a\u4e00\u4e2a\u6846\u67b6\u80fd\u4e0d\u80fd\u5728\u56e2\u961f\u91cc\u843d\u5730<\/span><\/strong><span leaf=\"\">\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u9664\u4e86\u4e09\u4ef6\u5957\uff0c\u522b\u5fd8\u4e86 Playwright \u81ea\u5e26\u7684&nbsp;<\/span><strong><span leaf=\"\">HTML \u62a5\u544a<\/span><\/strong><span leaf=\"\">\uff1a\u6267\u884c\u5b8c\u81ea\u52a8\u751f\u6210\u53ef\u4ea4\u4e92\u7684&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">playwright-report<\/span><\/code><span leaf=\"\">\uff0c\u70b9\u5f00\u5c31\u80fd\u770b\u6bcf\u6761\u7528\u4f8b\u7684\u622a\u56fe\u3001trace\u3001\u5931\u8d25\u5806\u6808\uff0c\u652f\u6301\u6309\u6d4f\u89c8\u5668\/\u72b6\u6001\u7b5b\u9009\uff0c\u5206\u4eab\u7ed9\u5f00\u53d1\u540c\u4e8b\u6392\u67e5\u4f53\u9a8c\u6781\u4f73\u3002\u65e5\u5e38\u4f60\u8fd8\u80fd\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright test --list<\/span><\/code><span leaf=\"\">&nbsp;\u5217\u51fa\u5c06\u8981\u6267\u884c\u7684\u7528\u4f8b\u3001\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--project<\/span><\/code><span leaf=\"\">&nbsp;\u7cbe\u786e\u6311\u9009\u5185\u6838\uff0c\u628a\u8c03\u8bd5\u8303\u56f4\u6536\u655b\u5230\u6700\u5c0f\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u62a5\u544a\u4e0e trace \u914d\u5408\u4f7f\u7528\uff0c\u662f\u56e2\u961f\u4ece\u201c\u8dd1\u5f97\u8d77\u6765\u201d\u8d70\u5411\u201c\u67e5\u5f97\u660e\u767d\u201d\u7684<\/span><strong><span leaf=\"\">\u5206\u6c34\u5cad<\/span><\/strong><span leaf=\"\">\u3002\u6211\u4eec\u56e2\u961f\u7684\u4e60\u60ef\u662f\uff1a\u672c\u5730\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--reporter=list<\/span><\/code><span leaf=\"\">&nbsp;\u770b\u6982\u8981\uff0cCI \u4e0a\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--reporter=html<\/span><\/code><span leaf=\"\">&nbsp;\u51fa\u5b8c\u6574\u62a5\u544a\u5e76\u5f52\u6863\uff1b\u5931\u8d25\u7528\u4f8b\u5f3a\u5236&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">trace: on-first-retry<\/span><\/code><span leaf=\"\">\uff0c\u8c01\u6539\u5d29\u4e86\u8c01\u81ea\u5df1\u70b9\u5f00 trace \u770b\u65f6\u95f4\u7ebf\uff0c\u57fa\u672c\u4e0d\u518d\u9700\u8981\u6d4b\u8bd5\u540c\u5b66\u53e3\u5934\u590d\u8ff0\u201c\u5f53\u65f6\u548b\u4e86\u201d\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">trace \u8fd8\u6709\u4e2a\u9ad8\u7ea7\u7528\u6cd5\uff1a<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--trace on<\/span><\/code><span leaf=\"\">&nbsp;\u5168\u91cf\u5f55\u5236\u540e\uff0c\u914d\u5408&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">playwright show-trace<\/span><\/code><span leaf=\"\">&nbsp;\u53ef\u62d6\u52a8\u56de\u653e\uff0c\u751a\u81f3\u5bfc\u51fa\u7ed9\u6ca1\u88c5 Playwright \u7684\u540c\u4e8b\u770b\u3002\u6211\u4eec\u66fe\u7528\u5b83\u5b9a\u4f4d\u8fc7\u4e00\u4e2a\u53ea\u5728 WebKit \u4e0a\u51fa\u73b0\u7684\u201c\u5b57\u4f53\u52a0\u8f7d\u95ea\u70c1\u5bfc\u81f4\u65ad\u8a00\u8bef\u5224\u201d\u95ee\u9898\u2014\u2014\u8089\u773c\u6839\u672c\u770b\u4e0d\u51fa\uff0c\u4f46 trace \u7684\u9010\u5e27\u5feb\u7167\u4e00\u773c\u5c31\u5bf9\u6bd4\u51fa\u6765\u4e86\u3002\u8c03\u8bd5\u5de5\u5177\u7684\u6295\u5165\u4ea7\u51fa\u6bd4\uff0c\u5f80\u5f80\u8d85\u4e4e\u9884\u671f\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u518d\u804a\u4e00\u4e2a\u5b9e\u6218\u7ec6\u8282\uff1a\u622a\u56fe\u9ed8\u8ba4\u622a\u89c6\u53e3\uff0c\u52a0&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">fullPage: true<\/span><\/code><span leaf=\"\">&nbsp;\u53ef\u622a\u6574\u9875\u957f\u56fe\uff0c\u9002\u5408\u6838\u5bf9\u201c\u9875\u9762\u662f\u5426\u6574\u4f53\u6e32\u67d3\u6b63\u5e38\u201d\uff1b\u89c6\u9891\u9ed8\u8ba4 WebM \u683c\u5f0f\uff0c\u53ef\u76f4\u63a5\u5728 HTML \u62a5\u544a\u91cc\u70b9\u5f00\u56de\u653e\uff0c\u6bd4\u622a\u56fe\u4fe1\u606f\u91cf\u5927\u5f97\u591a\u3002\u5f53 CI \u5931\u8d25\uff0c\u6211\u4eec\u4e60\u60ef\u5148\u770b\u89c6\u9891\u201c\u770b\u53d1\u751f\u4e86\u4ec0\u4e48\u201d\uff0c\u518d\u770b trace\u201c\u770b\u4e3a\u4ec0\u4e48\u201d\uff0c\u6700\u540e\u770b\u7f51\u7edc\u9762\u677f\u201c\u770b\u662f\u4e0d\u662f\u63a5\u53e3\u7684\u95ee\u9898\u201d\u2014\u2014\u8fd9\u4e09\u6b65\u57fa\u672c\u80fd\u7ed3\u6848\u516b\u6210\u4ee5\u4e0a\u7684 bug\u3002<\/span><\/p>\n<section style=\"text-align: center;text-indent: 2em;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\ud83d\udcf7 \u56fe5\uff1atrace viewer \u8c03\u8bd5\u754c\u9762\uff08\u6df1\u8272\u6a21\u62df\uff09<\/span><\/span><\/span><\/span><\/span><\/section>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000472\" data-s=\"300,640\" data-type=\"png\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/mmbiz_png\/BWmfcibGhS1Lm4mCfeRLXjQ0n17iczHGYoLUXOIvRHZBjcTwpOyNqnTAIcLbJC1JxKhc21MybicCF6PWY5b2jugVSrhseEXeq7nGc6cict6UQcA\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<section style=\"text-align: left;text-indent: 2em;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><br  \/><\/span><\/span><\/span><\/span><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 18px;color: rgb(26, 26, 46);border-left: 4px solid rgb(21, 101, 192);padding-left: 12px;margin: 36px 0px 16px;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u516d\u3001\u5b9e\u6218\uff1a\u4ece 0 \u5230 1 \u642d\u4e00\u4e2a\u8de8\u6d4f\u89c8\u5668\u6d4b\u8bd5\u5957\u4ef6<\/span><\/h2>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5149\u8bf4\u4e0d\u7ec3\u5047\u628a\u5f0f\u3002\u8fd9\u4e00\u7ae0\u6211\u4eec\u7528\u771f\u5b9e\u7f51\u7ad9&nbsp;<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">DemoBlaze<\/span><\/strong><span leaf=\"\">\uff08http:\/\/demoblaze.com\uff0c\u4e00\u4e2a\u7ecf\u5178\u7684\u7535\u5546\u6f14\u793a\u7ad9\uff09\u6765\u642d\u4e00\u5957\u5b8c\u6574\u7684\u8de8\u6d4f\u89c8\u5668\u5957\u4ef6\u3002\u5b83\u9875\u9762\u7b80\u5355\u3001\u65e0\u9700\u6ce8\u518c\u5373\u53ef\u52a0\u8d2d\uff0c\u975e\u5e38\u9002\u5408\u7ec3\u624b\u3002\u6211\u4eec\u89c4\u5212 4 \u4e2a\u7528\u4f8b\uff1a\u2460 \u9996\u9875\u52a0\u8f7d\u9a8c\u8bc1\uff1b\u2461 \u4ea7\u54c1\u5206\u7c7b\u5bfc\u822a\uff1b\u2462 \u6dfb\u52a0\u5546\u54c1\u5230\u8d2d\u7269\u8f66\uff1b\u2463 \u7b80\u5316\u7248\u7ed3\u7b97\u6d41\u7a0b\u3002\u4e4b\u6240\u4ee5\u9009\u5b83\uff0c\u662f\u56e0\u4e3a\u5b83\u771f\u5b9e\u5b58\u5728 DOM \u7ed3\u6784\u3001\u5f39\u7a97\uff08dialog\uff09\u3001\u5206\u7c7b\u5207\u6362\u7b49\u5178\u578b\u4ea4\u4e92\uff0c\u51e0\u4e4e\u8986\u76d6\u4e86 Web \u6d4b\u8bd5\u7684\u5168\u90e8\u5e38\u89c1\u573a\u666f\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u4e3a\u4e86\u8ba9\u4ee3\u7801\u53ef\u7ef4\u62a4\uff0c\u6211\u4eec\u91c7\u7528&nbsp;<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">Page Object \u6a21\u5f0f<\/span><\/strong><span leaf=\"\">\uff1a\u628a\u201c\u9875\u9762\u201d\u5c01\u88c5\u6210\u7c7b\uff0c\u6d4b\u8bd5\u53ea\u5173\u5fc3\u201c\u505a\u4ec0\u4e48\u201d\uff0c\u4e0d\u5173\u5fc3\u201c\u600e\u4e48\u5b9a\u4f4d\u201d\u3002\u5f53\u4ea7\u54c1\u6539\u7248\u3001\u9009\u62e9\u5668\u53d8\u66f4\u65f6\uff0c\u4f60\u53ea\u9700\u6539 Page Object \u4e00\u5904\uff0c\u6240\u6709\u7528\u4f8b\u81ea\u52a8\u9002\u914d\uff0c\u8fd9\u6b63\u662f\u5927\u578b\u9879\u76ee\u964d\u4f4e\u7ef4\u62a4\u6210\u672c\u7684\u5173\u952e\u3002\u5148\u5199\u4e00\u4e2a&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">HomePage<\/span><\/code><span leaf=\"\">&nbsp;\u548c&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">CartPage<\/span><\/code><span leaf=\"\">\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"typescript\"><code><span leaf=\"\"><span class=\"code-snippet__comment\">\/\/ pages\/homePage.ts<\/span><\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;{&nbsp;<span class=\"code-snippet__title\">Page<\/span>,&nbsp;<span class=\"code-snippet__title\">Locator<\/span>&nbsp;}&nbsp;<span class=\"code-snippet__keyword\">from<\/span>&nbsp;<span class=\"code-snippet__string\">'@playwright\/test'<\/span>;<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">export<\/span>&nbsp;<span class=\"code-snippet__keyword\">class<\/span>&nbsp;<span class=\"code-snippet__title\">HomePage<\/span>&nbsp;{<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__title\">constructor<\/span>(<span class=\"code-snippet__params\"><span class=\"code-snippet__keyword\">private<\/span><\/span><span class=\"code-snippet__params\">&nbsp;<\/span><span class=\"code-snippet__params\"><span class=\"code-snippet__attr\">page<\/span><\/span><span class=\"code-snippet__params\">:&nbsp;<\/span><span class=\"code-snippet__params\"><span class=\"code-snippet__title\">Page<\/span><\/span>) {}<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">async<\/span>&nbsp;<span class=\"code-snippet__title\">goto<\/span>() {<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;<span class=\"code-snippet__variable\">this<\/span>.<span class=\"code-snippet__property\">page<\/span>.<span class=\"code-snippet__title\">goto<\/span>(<span class=\"code-snippet__string\">'\/'<\/span>);<\/span><\/code><code><span leaf=\"\">&nbsp; }<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">async<\/span>&nbsp;<span class=\"code-snippet__title\">openCategory<\/span>(<span class=\"code-snippet__params\"><span class=\"code-snippet__attr\">name<\/span><\/span><span class=\"code-snippet__params\">:&nbsp;<\/span><span class=\"code-snippet__params\"><span class=\"code-snippet__built_in\">string<\/span><\/span>) {<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;<span class=\"code-snippet__variable\">this<\/span>.<span class=\"code-snippet__property\">page<\/span>.<span class=\"code-snippet__title\">getByRole<\/span>(<span class=\"code-snippet__string\">'link'<\/span>, { name }).<span class=\"code-snippet__title\">click<\/span>();<\/span><\/code><code><span leaf=\"\">&nbsp; }<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">async<\/span>&nbsp;<span class=\"code-snippet__title\">addFirstProductToCart<\/span>() {<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;<span class=\"code-snippet__variable\">this<\/span>.<span class=\"code-snippet__property\">page<\/span>.<span class=\"code-snippet__title\">locator<\/span>(<span class=\"code-snippet__string\">'.card-title'<\/span>).<span class=\"code-snippet__title\">first<\/span>().<span class=\"code-snippet__title\">click<\/span>();<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;<span class=\"code-snippet__variable\">this<\/span>.<span class=\"code-snippet__property\">page<\/span>.<span class=\"code-snippet__title\">getByRole<\/span>(<span class=\"code-snippet__string\">'link'<\/span>, {&nbsp;<span class=\"code-snippet__attr\">name<\/span>:&nbsp;<span class=\"code-snippet__string\">'Add to cart'<\/span>&nbsp;}).<span class=\"code-snippet__title\">click<\/span>();<\/span><\/code><code><span leaf=\"\">&nbsp; }<\/span><\/code><code><span leaf=\"\">}<\/span><\/code><\/pre>\n<\/section>\n<section style=\"text-align: left;text-indent: 2em;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 30px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;display: inline !important;float: none;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u518d\u5199\u4e00\u4e2a&nbsp;<\/span><\/span><code style=\"color: rgb(44, 44, 44);font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 30px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">CartPage<\/span><\/code><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 30px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;display: inline !important;float: none;\"><span leaf=\"\">&nbsp;\u8d1f\u8d23\u8d2d\u7269\u8f66\u4e0e\u7ed3\u7b97\u76f8\u5173\u64cd\u4f5c\uff0c\u628a\u201c\u70b9\u51fb\u8d2d\u7269\u8f66\u3001\u8bfb\u53d6\u603b\u4ef7\u3001\u8fdb\u5165\u7ed3\u7b97\u201d\u5c01\u88c5\u6210\u65b9\u6cd5\u3002\u8fd9\u6837\u6d4b\u8bd5\u6587\u4ef6\u5c31\u80fd\u4fdd\u6301\u6781\u9ad8\u7684\u53ef\u8bfb\u6027\u3002\u4e0b\u9762\u5199\u6d4b\u8bd5\u6587\u4ef6\uff0c\u903b\u8f91\u6e05\u6670\u5f97\u50cf\u5728\u5199\u9700\u6c42\u6587\u6863\uff1a<\/span><\/span><\/span><\/span><\/span><\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;{ test, expect }&nbsp;<span class=\"code-snippet__keyword\">from<\/span>&nbsp;<span class=\"code-snippet__string\">'@playwright\/test'<\/span>;<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__keyword\">import<\/span>&nbsp;{&nbsp;<span class=\"code-snippet__title\">HomePage<\/span>&nbsp;}&nbsp;<span class=\"code-snippet__keyword\">from<\/span>&nbsp;<span class=\"code-snippet__string\">'..\/pages\/homePage'<\/span>;<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__title\">test<\/span>(<span class=\"code-snippet__string\">'\u9996\u9875\u52a0\u8f7d\u5e76\u52a0\u8d2d\u5546\u54c1'<\/span>,&nbsp;<span class=\"code-snippet__title\">async<\/span>&nbsp;({ page }) =&gt; {<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">const<\/span>&nbsp;home =&nbsp;<span class=\"code-snippet__keyword\">new<\/span>&nbsp;<span class=\"code-snippet__title\">HomePage<\/span>(page);<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;home.<span class=\"code-snippet__title\">goto<\/span>();<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;<span class=\"code-snippet__title\">expect<\/span>(page).<span class=\"code-snippet__title\">toHaveTitle<\/span>(<span class=\"code-snippet__regexp\">\/STORE\/<\/span>);<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;home.<span class=\"code-snippet__title\">openCategory<\/span>(<span class=\"code-snippet__string\">'Laptops'<\/span>);<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__keyword\">await<\/span>&nbsp;home.<span class=\"code-snippet__title\">addFirstProductToCart<\/span>();&nbsp;<span class=\"code-snippet__comment\">\/\/ \u5f39\u7a97\u786e\u8ba4\u52a0\u8d2d\u6210\u529f<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; page.<span class=\"code-snippet__title\">once<\/span>(<span class=\"code-snippet__string\">'dialog'<\/span>,&nbsp;<span class=\"code-snippet__function\"><span class=\"code-snippet__params\">d<\/span><\/span><span class=\"code-snippet__function\">&nbsp;=&gt;<\/span>&nbsp;d.<span class=\"code-snippet__title\">accept<\/span>());<\/span><\/code><code><span leaf=\"\">});<\/span><\/code><\/pre>\n<\/section>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u56e0\u4e3a\u914d\u7f6e\u91cc\u5df2\u7ecf\u6302\u4e86\u4e09\u4e2a projects\uff0c\u76f4\u63a5&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright test<\/span><\/code><span leaf=\"\">\uff0c\u8fd9\u5957\u7528\u4f8b\u5c31\u4f1a\u5728 Chrome\u3001Firefox\u3001Safari \u5185\u6838\u4e0a\u5404\u8dd1\u4e00\u904d\u3002<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u4e00\u65e6\u67d0\u4e2a\u6d4f\u89c8\u5668\u51fa\u95ee\u9898\uff0c\u62a5\u544a\u4f1a\u7cbe\u786e\u544a\u8bc9\u4f60\u54ea\u4e00\u5185\u6838\u3001\u54ea\u4e00\u6b65\u3001\u5f53\u65f6\u7684\u622a\u56fe\u4e0e trace<\/span><\/strong><span leaf=\"\">\u2014\u2014\u8fd9\u5c31\u662f\u8de8\u6d4f\u89c8\u5668\u6d4b\u8bd5\u771f\u6b63\u843d\u5730\u8be5\u6709\u7684\u6837\u5b50\u3002\u5b9e\u6218\u4e2d\u8fd8\u6709\u4e00\u4e2a\u7ecf\u9a8c\uff1a\u7ed9\u5173\u952e\u5143\u7d20\u52a0\u4e0a&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">data-testid<\/span><\/code><span leaf=\"\">&nbsp;\u5c5e\u6027\uff0c\u5e76\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.getByTestId()<\/span><\/code><span leaf=\"\">&nbsp;\u5b9a\u4f4d\uff0c\u80fd\u628a\u6d4b\u8bd5\u4e0e\u89c6\u89c9\u6837\u5f0f\u5f7b\u5e95\u89e3\u8026\uff0c\u524d\u7aef\u6539\u7248\u4e0d\u4f1a\u52a8\u8f84\u8ba9\u6d4b\u8bd5\u5927\u9762\u79ef\u5d29\u584c\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u56de\u5230 DemoBlaze\uff0c<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">CartPage<\/span><\/code><span leaf=\"\">&nbsp;\u53ef\u4ee5\u5c01\u88c5\u201c\u6253\u5f00\u8d2d\u7269\u8f66\u3001\u8bfb\u53d6\u5546\u54c1\u603b\u6570\u3001\u8fdb\u5165 Place Order\u3001\u586b\u5199\u8868\u5355\u5e76\u63d0\u4ea4\u201d\u7b49\u65b9\u6cd5\uff0c\u6d4b\u8bd5\u91cc\u53ea\u9700&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">await cart.open(); await expect(cart.items).toHaveCount(1);<\/span><\/code><span leaf=\"\">&nbsp;\u8fd9\u6837\u58f0\u660e\u5f0f\u5730\u8868\u8fbe\u610f\u56fe\u3002\u628a\u201c\u9875\u9762\u7ed3\u6784\u201d\u548c\u201c\u4e1a\u52a1\u65ad\u8a00\u201d\u5206\u79bb\uff0c\u6b63\u662f Page Object \u6a21\u5f0f\u7684\u7cbe\u9ad3\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u66f4\u8fdb\u4e00\u6b65\uff0c\u7ed9\u9875\u9762\u5143\u7d20\u52a0&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">data-testid<\/span><\/code><span leaf=\"\">\uff08\u5982&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">data-testid=\"add-to-cart\"<\/span><\/code><span leaf=\"\">\uff09\u5e76\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.getByTestId()<\/span><\/code><span leaf=\"\">&nbsp;\u5b9a\u4f4d\uff0c\u80fd\u628a\u6d4b\u8bd5\u4e0e\u89c6\u89c9\u6837\u5f0f\u5f7b\u5e95\u89e3\u8026\u2014\u2014\u524d\u7aef\u54ea\u6015\u628a\u6309\u94ae\u4ece\u84dd\u8272\u6539\u6210\u7ea2\u8272\u3001\u4ece\u6587\u5b57\u6539\u6210\u56fe\u6807\uff0c\u6d4b\u8bd5\u4e5f\u7eb9\u4e1d\u4e0d\u52a8\u3002\u8fd9\u662f\u964d\u4f4e\u7ef4\u62a4\u6210\u672c\u6700\u5212\u7b97\u7684\u4e00\u7b14\u6295\u8d44\uff0c\u5efa\u8bae\u5728\u56e2\u961f\u89c4\u8303\u91cc\u76f4\u63a5\u5b9a\u4e3a\u201c\u65b0\u589e\u4ea4\u4e92\u5fc5\u987b\u5e26 testid\u201d\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u6700\u540e\u5f3a\u8c03\u6d4b\u8bd5\u6570\u636e\u95ee\u9898\uff1aDemoBlaze \u8fd9\u7c7b\u6f14\u793a\u7ad9\u65e0\u9700\u767b\u5f55\uff0c\u4f46\u771f\u5b9e\u7535\u5546\u5f80\u5f80\u6709\u5e93\u5b58\u3001\u4ef7\u683c\u3001\u767b\u5f55\u6001\u7b49\u52a8\u6001\u6570\u636e\u3002\u5efa\u8bae\u7528\u4f8b\u91cc\u7528\u201c\u76f8\u5bf9\u65ad\u8a00\u201d\uff08\u5982\u6570\u91cf\u52a0\u4e00\u3001\u603b\u989d\u53d8\u5927\uff09\u800c\u975e\u201c\u5199\u6b7b\u671f\u671b\u503c\u201d\uff0c\u5e76\u7528 storageState \u56fa\u5316\u767b\u5f55\u6001\uff0c\u907f\u514d\u88ab\u6570\u636e\u53d8\u52a8\u8bef\u4f24\u3002\u6d4b\u8bd5\u7684\u7a33\u5b9a\u6027\uff0c\u4e00\u534a\u5728\u5b9a\u4f4d\u5668\uff0c\u4e00\u534a\u5728\u6570\u636e\u7b56\u7565\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u987a\u4fbf\u8bf4\u4e00\u53e5\u5173\u4e8e\u201c\u6d4b\u8bd5\u8be5\u4e0d\u8be5\u52a8\u771f\u5b9e\u6570\u636e\u5e93\u201d\u7684\u8fb9\u754c\uff1aDemoBlaze \u7528\u7684\u662f\u516c\u5f00\u6f14\u793a\u6570\u636e\uff0c\u600e\u4e48\u9020\u90fd\u884c\uff1b\u4f46\u63a5\u771f\u5b9e\u7cfb\u7edf\u65f6\uff0c\u52a1\u5fc5\u8d70\u201c\u6d4b\u8bd5\u4e13\u7528\u73af\u5883 + \u72ec\u7acb\u6570\u636e\u201d\uff0c\u7528\u524d\u7f6e fixture \u9020\u6570\u3001\u540e\u7f6e fixture \u6e05\u6570\uff0c\u7edd\u4e0d\u5728\u751f\u4ea7\u5e93\u4e0a\u8dd1\u81ea\u52a8\u5316\u3002\u628a\u6570\u636e\u4e0e\u73af\u5883\u7684\u9694\u79bb\u5199\u8fdb\u89c4\u8303\uff0c\u80fd\u907f\u514d\u201c\u6d4b\u8bd5\u8dd1\u5b8c\uff0c\u8ba2\u5355\u91cc\u591a\u4e86\u4e00\u767e\u53f0\u7b14\u8bb0\u672c\u201d\u7684\u793e\u6b7b\u73b0\u573a\u3002<\/span><\/p>\n<section style=\"text-align: center;text-indent: 2em;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 30px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\ud83d\udcf7 \u56fe6\uff1aDemoBlaze \u6d4b\u8bd5\u533a\u57df\u6807\u6ce8\uff08\u6d4f\u89c8\u5668\u7a97\u53e3\u6a21\u62df\uff09<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/section>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000473\" data-s=\"300,640\" data-type=\"png\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/BWmfcibGhS1IVKhEhO4SACibWN4Ey5kBrM8mNDpuOZs8z7iaEdJrxp81tGxNFCFHzFpZuIkppqm5W6NnUlNXWjNd9qicV8eibEGnQez3qmstGlhE\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<section style=\"text-align: left;text-indent: 2em;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 30px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><br  \/><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 18px;color: rgb(26, 26, 46);border-left: 4px solid rgb(21, 101, 192);padding-left: 12px;margin: 36px 0px 16px;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u4e03\u3001CI\/CD \u96c6\u6210\uff1a\u8ba9\u6d4b\u8bd5\u5728\u6bcf\u6b21\u63d0\u4ea4\u65f6\u81ea\u52a8\u8dd1<\/span><\/h2>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u624b\u52a8\u8dd1\u6d4b\u8bd5\u7ec8\u7a76\u4e0d\u662f\u76ee\u7684\uff0c<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u628a\u6d4b\u8bd5\u63a5\u8fdb CI\/CD\uff0c\u8ba9\u5b83\u5728\u6bcf\u6b21 push \u548c pull request \u65f6\u81ea\u52a8\u6267\u884c<\/span><\/strong><span leaf=\"\">\uff0c\u624d\u662f\u5de5\u7a0b\u5316\u7684\u7ec8\u70b9\u3002\u4ee5 GitHub Actions \u4e3a\u4f8b\uff0c\u5728\u9879\u76ee\u6839\u76ee\u5f55\u5efa&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">.github\/workflows\/playwright.yml<\/span><\/code><span leaf=\"\">&nbsp;\u5373\u53ef\u3002CI \u7684\u4ef7\u503c\u4e0d\u53ea\u662f\u201c\u81ea\u52a8\u8dd1\u201d\uff0c\u66f4\u662f\u628a\u8d28\u91cf\u95e8\u7981\u524d\u79fb\u2014\u2014\u5728\u4ee3\u7801\u5408\u5e76\u524d\u5c31\u62e6\u4f4f\u56de\u5f52\uff0c\u907f\u514d\u95ee\u9898\u6d41\u5230\u7ebf\u4e0a\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5173\u952e\u914d\u7f6e\u6709\u4e09\u5904\uff1a<\/span><strong><span leaf=\"\">\u89e6\u53d1\u6761\u4ef6<\/span><\/strong><span leaf=\"\">\u8bbe\u4e3a&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">on: [push, pull_request]<\/span><\/code><span leaf=\"\">\uff0c\u4fdd\u8bc1\u4ee3\u7801\u4e00\u53d8\u52a8\u5c31\u6d4b\uff1b<\/span><strong><span leaf=\"\">\u77e9\u9635\u7b56\u7565<\/span><\/strong><span leaf=\"\">\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">matrix<\/span><\/code><span leaf=\"\">&nbsp;\u628a Node \u7248\u672c\u548c\u6d4f\u89c8\u5668\u7ec4\u5408\u5e76\u884c\uff0c\u7f29\u77ed\u603b\u8017\u65f6\uff1b<\/span><strong><span leaf=\"\">\u62a5\u544a\u4e0a\u4f20<\/span><\/strong><span leaf=\"\">\u7528\u5b98\u65b9 Action \u628a HTML \u62a5\u544a\u53d1\u5e03\u5230 GitHub Pages \u6216\u4f5c\u4e3a Artifact \u7559\u5b58\uff0c\u65b9\u4fbf\u56de\u6eaf\u3002\u4e0b\u9762\u662f\u4e00\u4efd\u53ef\u76f4\u63a5\u5957\u7528\u7684\u9aa8\u67b6\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"bash\"><code><span leaf=\"\"><span class=\"code-snippet__comment\"># .github\/workflows\/playwright.yml<\/span><\/span><\/code><code><span leaf=\"\">name: Playwright Tests<\/span><\/code><code><span leaf=\"\">on: [push, pull_request]<\/span><\/code><code><span leaf=\"\"><span class=\"code-snippet__built_in\">jobs<\/span>:<\/span><\/code><code><span leaf=\"\">&nbsp;&nbsp;<span class=\"code-snippet__built_in\">test<\/span>:<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; runs-on: ubuntu-latest<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; strategy:<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; matrix:<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; browser: [chromium, firefox, webkit]<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; steps:<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; - uses: actions\/checkout@v4<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; - uses: actions\/setup-node@v4<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; with:<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; node-version:&nbsp;<span class=\"code-snippet__string\">'20'<\/span><\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; - run: npm ci<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; - run: npx playwright install --with-deps<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; - run: npx playwright&nbsp;<span class=\"code-snippet__built_in\">test<\/span>&nbsp;--project=<span class=\"code-snippet__variable\">${{ matrix.browser }<\/span>}<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; - uses: actions\/upload-artifact@v4<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class=\"code-snippet__keyword\">if<\/span>: always()<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; with:<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: report-<span class=\"code-snippet__variable\">${{ matrix.browser }<\/span>}<\/span><\/code><code><span leaf=\"\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path: playwright-report\/<\/span><\/code><\/pre>\n<\/section>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u8fd9\u6837\uff0c\u4efb\u4f55\u4e00\u6b21\u63d0\u4ea4\u90fd\u4f1a\u5e76\u884c\u89e6\u53d1\u4e09\u6b21\u6d4b\u8bd5\uff08\u4e09\u4e2a\u6d4f\u89c8\u5668\u5404\u4e00\u6b21\uff09\uff0c\u8dd1\u5b8c\u81ea\u52a8\u628a\u62a5\u544a\u6253\u5305\u3002\u5982\u679c\u67d0\u4e2a\u6d4f\u89c8\u5668\u6302\u4e86\uff0cCI \u76f4\u63a5\u6807\u7ea2\uff0c<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u628a\u201c\u517c\u5bb9\u6027\u95ee\u9898\u201d\u62e6\u5728\u5408\u5e76\u4e4b\u524d<\/span><\/strong><span leaf=\"\">\u3002\u540e\u9762\u4f60\u8fd8\u53ef\u4ee5\u5728\u5408\u5e76\u5230\u4e3b\u5e72\u540e\uff0c\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">pull_request<\/span><\/code><span leaf=\"\">&nbsp;\u7684&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">paths-filter<\/span><\/code><span leaf=\"\">&nbsp;\u505a\u589e\u91cf\u6d4b\u8bd5\uff0c\u53ea\u8dd1\u53d7\u5f71\u54cd\u7684\u7528\u4f8b\uff0c\u8fdb\u4e00\u6b65\u538b\u7f29\u53cd\u9988\u65f6\u95f4\u3002\u5bf9\u4e8e\u81ea\u6258\u7ba1 Runner\uff0c\u8bb0\u5f97\u628a&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">playwright-report<\/span><\/code><span leaf=\"\">&nbsp;\u901a\u8fc7\u7f13\u5b58\uff08cache\uff09\u590d\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">node_modules<\/span><\/code><span leaf=\"\">&nbsp;\u4e0e\u6d4f\u89c8\u5668\uff0c\u80fd\u663e\u8457\u7f29\u77ed\u6d41\u6c34\u7ebf\u65f6\u957f\u3002\u90e8\u7f72\u5230 GitHub Pages \u65f6\uff0c\u914d\u5408&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">actions\/deploy-pages<\/span><\/code><span leaf=\"\">&nbsp;\u5373\u53ef\u8ba9\u5168\u5458\u968f\u65f6\u5728\u7ebf\u67e5\u770b\u5386\u53f2\u62a5\u544a\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u518d\u8865\u4e24\u4e2a CI \u5b9e\u6218\u8981\u70b9\u3002\u7b2c\u4e00\uff0c\u52a1\u5fc5\u7528<\/span><strong><span leaf=\"\">\u7f13\u5b58<\/span><\/strong><span leaf=\"\">\uff1a\u628a&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">node_modules<\/span><\/code><span leaf=\"\">&nbsp;\u548c Playwright \u6d4f\u89c8\u5668\u76ee\u5f55\uff08<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">~\/.cache\/ms-playwright<\/span><\/code><span leaf=\"\">\uff09\u6309 lock \u6587\u4ef6\u54c8\u5e0c\u7f13\u5b58\uff0c\u80fd\u7701\u4e0b\u6bcf\u6b21\u91cd\u65b0\u4e0b\u8f7d\u7684\u51e0\u5206\u949f\uff1b\u7b2c\u4e8c\uff0c\u628a\u6d4b\u8bd5\u7ed3\u679c\u63a5\u5230\u901a\u77e5\uff1a\u7ed3\u5408&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">actions\/upload-artifact<\/span><\/code><span leaf=\"\">&nbsp;\u4fdd\u7559\u6700\u8fd1 N \u6b21\u62a5\u544a\uff0c\u5e76\u5728\u5931\u8d25\u65f6\u901a\u8fc7 Webhook \u63a8\u9001\u5230\u98de\u4e66 \/ Slack \/ \u4f01\u4e1a\u5fae\u4fe1\uff0c\u8ba9\u201c\u8c01\u63d0\u4ea4\u7684\u4ee3\u7801\u628a Safari \u6d4b\u6302\u4e86\u201d\u7b2c\u4e00\u65f6\u95f4\u88ab\u5f53\u4e8b\u4eba\u770b\u5230\uff0c\u5f62\u6210\u8d28\u91cf\u95ed\u73af\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5f53\u9879\u76ee\u53d8\u5927\uff0c\u8fd8\u53ef\u4ee5\u5f15\u5165<\/span><strong><span leaf=\"\">\u5206\u5c42\u6267\u884c<\/span><\/strong><span leaf=\"\">\uff1aPR \u9636\u6bb5\u53ea\u8dd1\u5192\u70df\uff08<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--grep @smoke<\/span><\/code><span leaf=\"\">\uff09\uff0c\u5408\u5e76\u4e3b\u5e72\u518d\u8dd1\u5168\u91cf\uff1b\u4e3b\u5e72\u5168\u91cf\u7ed3\u679c\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--reporter=github<\/span><\/code><span leaf=\"\">&nbsp;\u76f4\u63a5\u663e\u793a\u5728 PR \u68c0\u67e5\u91cc\u3002\u914d\u5408\u5206\u7247\uff0c\u65e2\u80fd\u4fdd\u8bc1\u5feb\u901f\u53cd\u9988\uff0c\u53c8\u4e0d\u4e22\u8986\u76d6\u7387\u3002CI \u4e0d\u662f\u201c\u8dd1\u4e00\u904d\u6d4b\u8bd5\u201d\u90a3\u4e48\u7b80\u5355\uff0c\u800c\u662f\u4e00\u5957\u5173\u4e8e\u201c\u4f55\u65f6\u8dd1\u3001\u8dd1\u591a\u5c11\u3001\u6302\u4e86\u8c01\u77e5\u9053\u201d\u7684\u5de5\u7a0b\u6743\u8861\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5982\u679c\u56e2\u961f\u7528 GitLab CI\u3001Jenkins \u800c\u975e GitHub Actions\uff0c\u601d\u8def\u5b8c\u5168\u4e00\u81f4\uff1a\u7528\u5e76\u884c stage \u6216 matrix \u8dd1\u591a\u6d4f\u89c8\u5668\uff0c\u628a\u62a5\u544a\u4f5c\u4e3a artifact \u7559\u5b58\u3002\u5173\u952e\u662f\u628a\u201c\u6d4f\u89c8\u5668\u7ef4\u5ea6\u201d\u53d8\u6210\u6d41\u6c34\u7ebf\u7684\u4e00\u7b49\u516c\u6c11\uff0c\u800c\u4e0d\u662f\u4e8b\u540e\u8865\u4e00\u4e2a\u201c\u5076\u5c14\u8dd1\u8dd1\u201d\u7684 job\u3002\u53ea\u6709\u5f53\u6d4b\u8bd5\u6210\u4e3a\u5408\u5e76\u7684\u786c\u95e8\u69db\uff0c\u8de8\u6d4f\u89c8\u5668\u8986\u76d6\u624d\u771f\u6b63\u6709\u4ef7\u503c\uff0c\u5426\u5219\u5f88\u5bb9\u6613\u5728\u8d76\u5de5\u671f\u65f6\u88ab\u6084\u6084\u8df3\u8fc7\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u62a5\u544a\u7559\u5b58\u4e5f\u6709\u8bb2\u7a76\uff1aGitHub Actions \u7684 artifact \u9ed8\u8ba4\u4fdd\u7559 90 \u5929\uff0c\u5efa\u8bae\u914d&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">retention-days<\/span><\/code><span leaf=\"\">&nbsp;\u6309\u56e2\u961f\u9700\u8981\u6536\u7d27\uff1b\u82e5\u62a5\u544a\u8981\u957f\u671f\u5f52\u6863\u6216\u5bf9\u5916\u5c55\u793a\uff0c\u53d1\u5e03\u5230 GitHub Pages \u662f\u6700\u7701\u4e8b\u7684\u65b9\u6848\u3002\u6ce8\u610f\u522b\u628a\u542b\u654f\u611f\u4fe1\u606f\u7684 trace\uff08\u53ef\u80fd\u542b Cookie\u3001\u622a\u56fe\uff09\u516c\u5f00\u51fa\u53bb\uff0c\u5fc5\u8981\u65f6\u5bf9\u62a5\u544a\u505a\u8bbf\u95ee\u63a7\u5236\u3002\u5b89\u5168\u4e0e\u53ef\u8ffd\u6eaf\uff0c\u662f CI \u62a5\u544a\u7684\u4e24\u6839\u5e95\u7ebf\u3002<\/span><\/p>\n<figure style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 24px 0px;background: rgb(248, 250, 252);border: 1px solid rgb(226, 232, 240);border-radius: 10px;padding: 20px;text-align: center;\">\n<p><span leaf=\"\">\ud83d\udcf7 \u56fe7\uff1aGitHub Actions \u6267\u884c\u65e5\u5fd7\uff08\u77e9\u9635\u5e76\u884c\uff09<\/span><\/p>\n<section style=\"text-align: center;\" nodeleaf=\"\">\n<figure class=\"wx-qr-wrap\"><img decoding=\"async\" class=\"rich_pages wxw-img\" data-aistatus=\"1\" data-imgfileid=\"100000474\" data-s=\"300,640\" data-type=\"png\" type=\"block\" src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/BWmfcibGhS1JUVZ4maHBqYq6yZvX9g87z2KKiazdiaHKAcjkd3zOf2aO7nUDw5uUsK3LIia9LC2UqqN0PCMaGqOUyD2oRftqfW5EZENQjib5xd2s\/640?wx_fmt=png&#038;from=appmsg\" \/><figcaption class=\"wx-qr-tip\"><img decoding=\"async\" src=\"https:\/\/www.deartester.com\/wp-content\/uploads\/2026\/09\/wechat-qr.jpg\" alt=\"\u5fae\u4fe1\u516c\u4f17\u53f7\u4e8c\u7ef4\u7801\" loading=\"lazy\"><span>\u56fe\u7247\u5f15\u81ea\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u626b\u7801\u5173\u6ce8\u9605\u8bfb\u539f\u6587<\/span><\/figcaption><\/figure>\n<\/section>\n<\/figure>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 18px;color: rgb(26, 26, 46);border-left: 4px solid rgb(21, 101, 192);padding-left: 12px;margin: 36px 0px 16px;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u516b\u3001\u5e38\u89c1\u95ee\u9898\u4e0e\u89e3\u51b3\u65b9\u6848\u901f\u67e5<\/span><\/h2>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u843d\u5730\u8fc7\u7a0b\u4e2d\u603b\u4f1a\u8e29\u5751\uff0c\u8fd9\u91cc\u628a\u9ad8\u9891\u95ee\u9898\u6574\u7406\u6210\u4e00\u5f20\u901f\u67e5\u8868\uff0c\u5efa\u8bae\u6536\u85cf\u3002\u591a\u6570\u95ee\u9898\u6839\u56e0\u90fd\u6307\u5411\u201c\u7b49\u5f85\u7b56\u7565\u201d\u548c\u201c\u9009\u62e9\u5668\u7a33\u5b9a\u6027\u201d\u4e24\u70b9\uff0c\u7262\u8bb0<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u4f18\u5148\u81ea\u52a8\u7b49\u5f85\u3001\u4f18\u5148\u7a33\u5b9a\u9009\u62e9\u5668<\/span><\/strong><span leaf=\"\">\u5373\u53ef\u907f\u5f00\u5927\u534a\u3002\u5f53\u6d4b\u8bd5\u5076\u53d1\u5931\u8d25\u65f6\uff0c\u5148\u7528 trace \u56de\u653e\u786e\u8ba4\u662f\u201c\u5143\u7d20\u771f\u7684\u6ca1\u51fa\u73b0\u201d\u8fd8\u662f\u201c\u5b9a\u4f4d\u5668\u5199\u9519\u201d\uff0c\u518d\u5bf9\u75c7\u4e0b\u836f\uff0c\u907f\u514d\u76f2\u76ee\u52a0\u8d85\u65f6\u63a9\u76d6\u771f\u5b9e\u7f3a\u9677\u3002<\/span><\/p>\n<table style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;width: 680px;border-collapse: collapse;margin: 16px 0px;font-size: 13px;\">\n<tbody>\n<tr style=\"background: rgb(21, 101, 192);color: rgb(255, 255, 255);\">\n<th style=\"padding: 10px 12px;border: 1px solid rgb(221, 221, 221);text-align: left;\">\n<section style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;\">\u95ee\u9898<\/span><\/span><\/section>\n<\/th>\n<th style=\"padding: 10px 12px;border: 1px solid rgb(221, 221, 221);text-align: left;\">\n<section style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;\">\u53ef\u80fd\u539f\u56e0<\/span><\/span><\/section>\n<\/th>\n<th style=\"padding: 10px 12px;border: 1px solid rgb(221, 221, 221);text-align: left;\">\n<section style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;\">\u89e3\u51b3\u65b9\u6848<\/span><\/span><\/section>\n<\/th>\n<\/tr>\n<tr>\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u6d4b\u8bd5\u8d85\u65f6\u5931\u8d25<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u7f51\u7edc\u6162 \/ \u5143\u7d20\u672a\u53ca\u65f6\u52a0\u8f7d<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u589e\u52a0 timeout\uff0c\u6216\u6539\u7528\u81ea\u52a8\u7b49\u5f85\u800c\u975e sleep<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(241, 245, 249);\">\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u5143\u7d20\u627e\u4e0d\u5230<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u9009\u62e9\u5668\u8106\u5f31\uff08\u968f\u673a class\u3001\u5c42\u7ea7\u6df1\uff09<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u7528 data-testid \u6216 getByRole \u66ff\u4ee3 CSS<\/span><\/section>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u4ec5\u67d0\u6d4f\u89c8\u5668\u5931\u8d25<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">CSS\/JS \u517c\u5bb9\u5dee\u5f02\uff08\u5982 Safari\uff09<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u5206\u79bb\u6d4f\u89c8\u5668\u7279\u5b9a\u65ad\u8a00\uff0c\u9488\u5bf9\u6027\u4fee\u590d<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(241, 245, 249);\">\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u767b\u5f55\u6001\u4e22\u5931<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u4e0a\u4e0b\u6587\u672a\u590d\u7528 Cookie<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px 12px;border: 1px solid rgb(221, 221, 221);\">\n<section><span leaf=\"\">\u7528 storageState \u7ba1\u7406\u767b\u5f55\u6001\u5e76\u590d\u7528<\/span><\/section>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u8865\u5145\u4e24\u4e2a\u5b9e\u7528\u6280\u5de7\uff1a<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">storageState<\/span><\/strong><span leaf=\"\">&nbsp;\u53ef\u4ee5\u8ba9\u4f60\u5148\u624b\u52a8\u767b\u5f55\u4e00\u6b21\uff0c\u628a Cookie \u5b58\u6210 JSON\uff0c\u4e4b\u540e\u6240\u6709\u7528\u4f8b\u76f4\u63a5\u52a0\u8f7d\u8fd9\u4e2a\u72b6\u6001\uff0c\u514d\u53bb\u4e86\u6bcf\u6b21\u91cd\u65b0\u767b\u5f55\u7684\u8017\u65f6\u4e0e flaky\uff1b\u800c&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--trace on<\/span><\/code><span leaf=\"\">&nbsp;\u914d\u5408&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">--debug<\/span><\/code><span leaf=\"\">&nbsp;\u6a21\u5f0f\uff0c\u80fd\u8ba9\u4f60\u5728\u4ea4\u4e92\u5f0f\u8c03\u8bd5\u91cc\u4e00\u6b65\u6b65\u770b\u9875\u9762\u53d1\u751f\u4e86\u4ec0\u4e48\uff0c\u5b9a\u4f4d\u95ee\u9898\u7684\u901f\u5ea6\u6bd4\u201c\u52a0\u6253\u5370\u201d\u5feb\u5341\u500d\u3002\u5982\u679c\u4ecd\u9047\u5230\u5076\u53d1\u5931\u8d25\uff0c\u4f18\u5148\u5f00\u542f&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">retries: 2<\/span><\/code><span leaf=\"\">&nbsp;\u5e76\u67e5\u770b\u91cd\u8bd5\u540e\u7684 trace\uff0c\u901a\u5e38\u80fd\u533a\u5206\u201c\u771f bug\u201d\u4e0e\u201c\u73af\u5883\u6296\u52a8\u201d\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u6700\u540e\u518d\u9001\u4e24\u4e2a\u8fdb\u9636\u62db\u5f0f\u3002\u5176\u4e00\u662f&nbsp;<\/span><strong><span leaf=\"\">\u7f51\u7edc\u62e6\u622a<\/span><\/strong><span leaf=\"\">\uff1a\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">page.route()<\/span><\/code><span leaf=\"\">&nbsp;\u53ef\u4ee5 mock \u63a5\u53e3\u8fd4\u56de\u3001\u6a21\u62df\u5f31\u7f51\u6216 500 \u9519\u8bef\uff0c\u4e13\u95e8\u6d4b\u8bd5\u524d\u7aef\u5728\u5f02\u5e38\u7f51\u7edc\u4e0b\u7684\u8868\u73b0\uff0c\u4e14\u5bf9\u4e09\u79cd\u6d4f\u89c8\u5668\u540c\u6837\u751f\u6548\uff1b\u5176\u4e8c\u662f&nbsp;<\/span><strong><span leaf=\"\">\u8f6f\u786c\u7b49\u5f85\u7ed3\u5408<\/span><\/strong><span leaf=\"\">\uff1a\u7edd\u5927\u591a\u6570\u573a\u666f\u4ea4\u7ed9\u81ea\u52a8\u7b49\u5f85\u5373\u53ef\uff0c\u53ea\u6709\u6781\u5c11\u6570\u201c\u52a8\u753b\u5f7b\u5e95\u7ed3\u675f\u201d\u7c7b\u65ad\u8a00\u624d\u9700\u8981&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">expect<\/span><\/code><span leaf=\"\">&nbsp;\u914d\u5408&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">state: 'hidden'<\/span><\/code><span leaf=\"\">&nbsp;\u4e4b\u7c7b\u7cbe\u786e\u6761\u4ef6\u3002\u628a\u8fd9\u5f20\u8868\u52a0\u4e24\u62db\u6536\u8fdb\u56e2\u961f Wiki\uff0c\u65b0\u4eba\u6392\u9519\u6548\u7387\u80fd\u63d0\u5347\u4e00\u5927\u622a\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u8fd8\u6709\u4e00\u4e2a\u9ad8\u9891\u8bef\u4f1a\u8981\u6f84\u6e05\uff1a\u5f88\u591a\u4eba\u628a\u201c\u6d4b\u8bd5\u4e0d\u7a33\u5b9a\u201d\u5f52\u548e\u4e8e\u6846\u67b6\uff0c\u5176\u5b9e\u591a\u534a\u662f<\/span><strong><span leaf=\"\">\u5b9a\u4f4d\u5668\u6216\u7b49\u5f85\u7b56\u7565\u7684\u95ee\u9898<\/span><\/strong><span leaf=\"\">\u3002\u5148\u5f00 trace \u56de\u653e\u786e\u8ba4\u201c\u5143\u7d20\u5230\u5e95\u6709\u6ca1\u6709\u51fa\u73b0\u3001\u51fa\u73b0\u5728\u54ea\u4e00\u6b65\u201d\uff0c\u518d\u51b3\u5b9a\u6539\u9009\u62e9\u5668\u8fd8\u662f\u6539\u8d85\u65f6\uff0c\u5207\u5fcc\u4e00\u4e0a\u6765\u5c31\u5168\u5c40\u52a0\u957f timeout \u63a9\u76d6\u95ee\u9898\u2014\u2014\u90a3\u53ea\u4f1a\u8ba9\u5957\u4ef6\u8d8a\u6765\u8d8a\u6162\u3001\u95ee\u9898\u8d8a\u6765\u8d8a\u9690\u853d\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u628a\u8fd9\u516b\u4e2a\u7ae0\u8282\u4e32\u8d77\u6765\u770b\uff0cPlaywright \u7684\u771f\u6b63\u4ef7\u503c\u4e0d\u5728\u4e8e\u201c\u80fd\u9a71\u52a8\u6d4f\u89c8\u5668\u201d\uff0c\u800c\u5728\u4e8e\u5b83\u628a\u201c\u5f55\u5236\u3001\u5b9a\u4f4d\u3001\u7b49\u5f85\u3001\u65ad\u8a00\u3001\u8c03\u8bd5\u3001\u5e76\u884c\u3001CI\u201d\u6574\u6210\u4e86\u4e00\u4e2a\u8fde\u8d2f\u7684\u4f53\u9a8c\u3002\u8fc7\u53bb\u8fd9\u4e9b\u73af\u8282\u5206\u6563\u5728 Selenium + \u5404\u79cd\u63d2\u4ef6 + \u81ea\u7814\u811a\u672c\u91cc\uff0c\u73b0\u5728\u88ab\u4e00\u4e2a\u6846\u67b6\u7edf\u4e00\u6536\u53e3\u3002\u7406\u89e3\u4e86\u8fd9\u4e00\u70b9\uff0c\u4f60\u5c31\u4e0d\u4f1a\u628a\u5b83\u5f53\u6210\u53c8\u4e00\u4e2a\u5de5\u5177\uff0c\u800c\u662f\u5f53\u6210\u4e00\u5957\u201c\u6d4b\u8bd5\u5de5\u7a0b\u5316\u201d\u7684\u65b9\u6cd5\u8bba\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u628a\u8fd9\u5957\u65b9\u6cd5\u653e\u8fdb\u56e2\u961f\u4e60\u60ef\u91cc\uff0c\u6bd4\u4e00\u6b21\u5199\u5bf9\u66f4\u91cd\u8981\u3002\u6bd4\u5982\u89c4\u5b9a\uff1a\u65b0\u589e\u9875\u9762\u5fc5\u987b\u5e26 testid\u3001\u65b0\u7528\u4f8b\u5fc5\u987b\u4e09\u5185\u6838\u8dd1\u901a\u624d\u5408\u5165\u3001\u5931\u8d25\u5fc5\u987b\u770b trace \u518d\u6539\u3002\u89c4\u5219\u4e00\u5f00\u59cb\u4f1a\u8ba9\u4eba\u4e0d\u4e60\u60ef\uff0c\u4f46\u575a\u6301\u51e0\u5468\uff0cflaky \u81ea\u7136\u53d8\u5c11\u3001\u6392\u9519\u65f6\u95f4\u8089\u773c\u53ef\u89c1\u5730\u4e0b\u964d\u3002\u5de5\u5177\u53ea\u662f\u653e\u5927\u5668\uff0c\u771f\u6b63\u51b3\u5b9a\u6d4b\u8bd5\u8d28\u91cf\u7684\uff0c\u8fd8\u662f\u56e2\u961f\u7ea6\u5b9a\u4fd7\u6210\u7684\u5de5\u7a0b\u7eaa\u5f8b\u3002<\/span><\/p>\n<figure style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;margin: 24px 0px;background: rgb(248, 250, 252);border: 1px solid rgb(226, 232, 240);border-radius: 10px;padding: 20px;text-align: center;\">\n<p><span leaf=\"\">\ud83d\udcf7 \u56fe8\uff1aPlaywright \u4e0e Selenium \u4e94\u7ef4\u5bf9\u6bd4<\/span><\/p>\n<table style=\"max-width:520px;margin:0px auto;border-collapse:collapse;font-size:12.5px;min-width:229px;\">\n<tbody>\n<tr style=\"background: rgb(21, 101, 192);color: rgb(255, 255, 255);\">\n<th data-colwidth=\"179\" style=\"padding: 9px;border: 1px solid rgb(205, 215, 227);text-align: left;\">\n<section style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;\">\u7ef4\u5ea6<\/span><\/span><\/section>\n<\/th>\n<th style=\"padding: 9px;border: 1px solid rgb(205, 215, 227);text-align: left;\">\n<section style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;\">Playwright<\/span><\/span><\/section>\n<\/th>\n<th style=\"padding: 9px;border: 1px solid rgb(205, 215, 227);text-align: left;\">\n<section style=\"text-align: center;\"><span leaf=\"\"><span textstyle=\"\" style=\"color: #d92142;\">Selenium<\/span><\/span><\/section>\n<\/th>\n<\/tr>\n<tr>\n<td data-colwidth=\"179\" style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);text-align: left;font-weight: bold;\">\n<section><span leaf=\"\">\u81ea\u52a8\u7b49\u5f85<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);\">\n<section><span leaf=\"\">\u2713 \u5185\u7f6e\u9ed8\u8ba4<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);color: rgb(220, 38, 38);\">\n<section><span leaf=\"\">\u2717 \u9700\u624b\u5199<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(241, 245, 249);\">\n<td data-colwidth=\"179\" style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);text-align: left;font-weight: bold;\">\n<section><span leaf=\"\">API \u8bbe\u8ba1<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);\">\n<section><span leaf=\"\">\u7b80\u6d01\u7edf\u4e00<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);color: rgb(210, 153, 34);\">\n<section><span leaf=\"\">\u8f83\u7e41\u7410<\/span><\/section>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"179\" style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);text-align: left;font-weight: bold;\">\n<section><span leaf=\"\">\u6d4f\u89c8\u5668\u652f\u6301<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);\">\n<section><span leaf=\"\">\u4e09\u5185\u6838\u4e00\u4f53\u5316<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);\">\n<section><span leaf=\"\">\u5168\u9762<\/span><\/section>\n<\/td>\n<\/tr>\n<tr style=\"background: rgb(241, 245, 249);\">\n<td data-colwidth=\"179\" style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);text-align: left;font-weight: bold;\">\n<section><span leaf=\"\">\u8c03\u8bd5\u5de5\u5177<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);\">\n<section><span leaf=\"\">Trace\/Codegen<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);color: rgb(220, 38, 38);\">\n<section><span leaf=\"\">\u8f83\u5f31<\/span><\/section>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"179\" style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);text-align: left;font-weight: bold;\">\n<section><span leaf=\"\">\u5b66\u4e60\u66f2\u7ebf<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);color: rgb(22, 163, 74);\">\n<section><span leaf=\"\">\u5e73\u7f13<\/span><\/section>\n<\/td>\n<td style=\"padding: 8px;border: 1px solid rgb(205, 215, 227);color: rgb(210, 153, 34);\">\n<section><span leaf=\"\">\u504f\u9661<\/span><\/section>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<section style=\"text-align: left;text-indent: 2em;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 30px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(255, 255, 255);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\"><span style=\"color: rgb(136, 136, 136);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 12px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;background-color: rgb(248, 250, 252);text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;float: none;display: inline !important;\" data-pm-slice=\"0 0 []\"><span leaf=\"\"><br  \/><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/section>\n<hr style=\"border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);\"  \/>\n<h2 style=\"font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;font-size: 18px;color: rgb(26, 26, 46);border-left: 4px solid rgb(21, 101, 192);padding-left: 12px;margin: 36px 0px 16px;\" data-pm-slice=\"0 0 []\"><span leaf=\"\">\u603b\u7ed3\uff1a\u4e09\u6b65\u5165\u95e8\uff0c\u8ba9\u8de8\u6d4f\u89c8\u5668\u6d4b\u8bd5\u4e0d\u518d\u5934\u75bc<\/span><\/h2>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">Playwright \u9002\u5408\u8c01\uff1f<\/span><\/strong><span leaf=\"\">\u5b83\u7279\u522b\u9002\u5408\u9700\u8981\u8986\u76d6 Chrome\u3001Firefox\u3001Safari \u591a\u5185\u6838\u7684 Web \u6d4b\u8bd5\u56e2\u961f\uff0c\u4e5f\u9002\u5408\u60f3\u7528\u66f4\u5c11\u4ee3\u7801\u83b7\u5f97\u66f4\u9ad8\u7a33\u5b9a\u6027\u7684\u5de5\u7a0b\u5316\u9879\u76ee\u3002\u5b83\u7684\u6838\u5fc3\u4f18\u52bf\u53ef\u4ee5\u6d53\u7f29\u6210\u4e09\u70b9\uff1a<\/span><strong><span leaf=\"\">\u81ea\u52a8\u7b49\u5f85<\/span><\/strong><span leaf=\"\">\u8ba9\u811a\u672c\u4e0d\u518d\u548c\u65f6\u5e8f\u8f83\u52b2\u3001<\/span><strong><span leaf=\"\">API \u7b80\u6d01<\/span><\/strong><span leaf=\"\">\u964d\u4f4e\u7ef4\u62a4\u6210\u672c\u3001<\/span><strong><span leaf=\"\">\u8c03\u8bd5\u5de5\u5177\u5f3a\u5927<\/span><\/strong><span leaf=\"\">\uff08codegen \u5f55\u5236 + trace viewer \u56de\u653e\uff09\u8ba9\u6392\u9519\u6548\u7387\u7ffb\u500d\u3002\u76f8\u6bd4\u4f20\u7edf Selenium\uff0c\u5b83\u5728\u201c\u5c11\u8e29\u5751\u3001\u6613\u7ef4\u62a4\u3001\u4e0a\u624b\u5feb\u201d\u8fd9\u4e09\u70b9\u4e0a\u51e0\u4e4e\u5168\u9762\u5360\u4f18\uff0c\u662f\u5f53\u4e0b Web \u81ea\u52a8\u5316\u6d4b\u8bd5\u6700\u52a1\u5b9e\u7684\u9009\u62e9\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5982\u679c\u4f60\u73b0\u5728\u5c31\u60f3\u52a8\u624b\uff0c\u53ea\u9700\u8bb0\u4f4f<\/span><strong style=\"color: rgb(21, 101, 192);\"><span leaf=\"\">\u4e09\u6b65\u8d70\u5feb\u901f\u4e0a\u624b\u6e05\u5355<\/span><\/strong><span leaf=\"\">\uff1a\u7b2c\u4e00\u6b65\uff0c<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npm install -D @playwright\/test &amp;&amp; npx playwright install<\/span><\/code><span leaf=\"\">&nbsp;\u88c5\u597d\u73af\u5883\uff1b\u7b2c\u4e8c\u6b65\uff0c<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright codegen<\/span><\/code><span leaf=\"\">&nbsp;\u96f6\u4ee3\u7801\u5f55\u5236\u51fa\u7b2c\u4e00\u4efd\u811a\u672c\u9aa8\u67b6\uff1b\u7b2c\u4e09\u6b65\uff0c\u6574\u7406\u6210\u89c4\u8303\u7528\u4f8b\u540e\uff0c<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright test<\/span><\/code><span leaf=\"\">&nbsp;\u4e00\u952e\u8dd1\u904d\u4e09\u6d4f\u89c8\u5668\u3002\u5168\u7a0b\u534a\u5c0f\u65f6\uff0c\u4f60\u5c31\u80fd\u62e5\u6709\u4eba\u751f\u7b2c\u4e00\u4e2a\u8de8\u6d4f\u89c8\u5668\u6d4b\u8bd5\u5957\u4ef6\u3002\u5f53\u5957\u4ef6\u7a33\u5b9a\u540e\uff0c\u518d\u6309\u7b2c\u4e03\u7ae0\u628a\u5b83\u63a5\u8fdb CI\/CD\uff0c\u8d28\u91cf\u95e8\u7981\u5c31\u771f\u6b63\u7acb\u8d77\u6765\u4e86\u3002\u5efa\u8bae\u628a\u672c\u6587\u6536\u85cf\uff0c\u7167\u7740\u6bcf\u4e00\u7ae0\u7684\u547d\u4ee4\u884c\u4e0e\u4ee3\u7801\u9010\u6761\u5b9e\u64cd\u4e00\u904d\uff0c\u6bd4\u5355\u7eaf\u770b\u6587\u6863\u6536\u83b7\u8981\u5927\u5f97\u591a\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u6700\u540e\u9001\u4f60\u4e00\u4efd<\/span><strong><span leaf=\"\">\u5feb\u901f\u81ea\u67e5\u6e05\u5355<\/span><\/strong><span leaf=\"\">\uff1a\u2460 \u662f\u5426\u7528&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">getByRole\/getByTestId<\/span><\/code><span leaf=\"\">&nbsp;\u66ff\u4ee3\u4e86\u8106\u5f31 CSS\uff1f\u2461 \u662f\u5426\u675c\u7edd\u4e86&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">waitForTimeout<\/span><\/code><span leaf=\"\">&nbsp;\u76f2\u7b49\uff1f\u2462 \u5931\u8d25\u7528\u4f8b\u662f\u5426\u81ea\u52a8\u5f55\u4e86 trace\uff1f\u2463 \u4e09\u4e2a\u5185\u6838\u662f\u5426\u90fd\u8dd1\u901a\uff1f\u2464 \u662f\u5426\u63a5\u8fdb\u4e86 CI \u6bcf\u6b21\u63d0\u4ea4\u81ea\u52a8\u6267\u884c\uff1f\u8fd9\u4e94\u6761\u5168\u7eff\uff0c\u4f60\u7684\u8de8\u6d4f\u89c8\u5668\u6d4b\u8bd5\u4f53\u7cfb\u5c31\u57fa\u672c\u6210\u719f\u4e86\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">Playwright \u4e0d\u795e\u79d8\uff0c\u96be\u7684\u5f80\u5f80\u662f\u201c\u5f00\u59cb\u52a8\u624b\u201d\u3002\u5b83\u628a\u8fc7\u53bb\u9700\u8981\u5199\u51e0\u5341\u884c\u80f6\u6c34\u4ee3\u7801\u624d\u80fd\u505a\u7684\u4e8b\uff0c\u6536\u655b\u6210\u4e86\u51e0\u6761\u76f4\u89c2\u7684 API \u548c\u4e00\u628a\u597d\u7528\u7684\u5de5\u5177\u94fe\u3002\u4e0e\u5176\u5728\u9009\u578b\u6587\u6863\u91cc\u7ea0\u7ed3\uff0c\u4e0d\u5982\u73b0\u5728\u5c31\u6253\u5f00\u7ec8\u7aef\uff0c\u4ece&nbsp;<\/span><code style=\"background: rgb(226, 232, 240);padding: 1px 5px;border-radius: 3px;\"><span leaf=\"\">npx playwright codegen<\/span><\/code><span leaf=\"\">&nbsp;\u6572\u4e0b\u7b2c\u4e00\u884c\u5f55\u5236\uff0c\u534a\u5c0f\u65f6\u540e\u4f60\u5c31\u80fd\u611f\u53d7\u5230\uff1a\u8de8\u6d4f\u89c8\u5668\u6d4b\u8bd5\uff0c\u539f\u6765\u53ef\u4ee5\u8fd9\u4e48\u987a\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u5982\u679c\u4f60\u8bfb\u5230\u8fd9\u91cc\u8fd8\u6ca1\u52a8\u624b\uff0c\u4e0d\u59a8\u628a\u672c\u6587\u6536\u85cf\uff0c\u4eca\u665a\u82b1\u534a\u5c0f\u65f6\u7167\u7740\u7b2c\u4e8c\u7ae0\u8dd1\u4e00\u904d codegen\u3002\u8de8\u6d4f\u89c8\u5668\u6d4b\u8bd5\u7684\u95e8\u69db\uff0c\u8fdc\u6bd4\u4f60\u60f3\u8c61\u4e2d\u4f4e\uff1b\u800c\u5b83\u80fd\u5728\u4e0a\u7ebf\u524d\u62e6\u4f4f\u7684\u90a3\u51e0\u4e2a\u517c\u5bb9\u6027\u4e8b\u6545\uff0c\u4ef7\u503c\u8fdc\u8d85\u8fd9\u51e0\u884c\u914d\u7f6e\u3002\u671f\u5f85\u5728\u8bc4\u8bba\u533a\u770b\u5230\u4f60\u7b2c\u4e00\u6b21\u8dd1\u901a\u4e09\u5185\u6838\u7684\u6218\u62a5\u3002<\/span><\/p>\n<p style=\"color: rgb(44, 44, 44);font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif;font-size: 15px;font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;white-space: normal;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;text-indent: 2em;\"><span leaf=\"\">\u6700\u540e\uff0c\u7ed9\u8d1f\u8d23\u4eba\u4e00\u53e5\u8bdd\uff1a\u522b\u628a\u81ea\u52a8\u5316\u6d4b\u8bd5\u5f53\u6210\u201c\u6d4b\u8bd5\u540c\u5b66\u7684\u4e8b\u201d\uff0c\u5b83\u672c\u8d28\u662f\u7814\u53d1\u6d41\u7a0b\u7684\u8d28\u91cf\u57fa\u7840\u8bbe\u65bd\u3002\u5f53\u4f60\u628a Playwright \u63a5\u8fdb CI\u3001\u628a\u4e09\u5185\u6838\u53d8\u6210\u5408\u5e76\u95e8\u69db\uff0c\u4f60\u4e70\u7684\u4e0d\u662f\u51e0\u884c\u811a\u672c\uff0c\u800c\u662f\u201c\u6bcf\u6b21\u63d0\u4ea4\u90fd\u81ea\u52a8\u6709\u4eba\u5e2e\u4f60\u76ef\u4f4f\u517c\u5bb9\u6027\u201d\u7684\u5b89\u5fc3\u3002\u8fd9\u7b14\u6295\u5165\uff0c\u4f1a\u968f\u9879\u76ee\u53d8\u5927\u800c\u6108\u53d1\u5212\u7b97\u3002\u73b0\u5728\uff0c\u5c31\u4ece\u5b89\u88c5\u90a3\u4e24\u6761\u547d\u4ee4\u5f00\u59cb\u5427\u3002<\/span><\/p>\n<p style=\"display: none;\"><mp-style-type data-value=\"3\"><\/mp-style-type><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udccc \u5bfc\u8bfb \u5982\u679c\u4f60\u5728\u6d4b\u8bd5\u56e2\u961f\u91cc\u5f85\u8fc7\u4e00\u6bb5\u65f6\u95f4\uff0c\u4e00\u5b9a\u5bf9 Selenium \u7684\u90a3\u4e9b\u201c\u8001\u6bdb\u75c5\u201d\u4e0d\u964c\u751f\uff1a\u5143\u7d20\u8fd8\u6ca1\u52a0\u8f7d\u5b8c\u5c31\u62a5 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":124,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-125","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai"],"_links":{"self":[{"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/posts\/125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/comments?post=125"}],"version-history":[{"count":1,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/posts\/125\/revisions"}],"predecessor-version":[{"id":214,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/posts\/125\/revisions\/214"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/media\/124"}],"wp:attachment":[{"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/media?parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/categories?post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.deartester.com\/index.php\/wp-json\/wp\/v2\/tags?post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}