{"id":122407,"date":"2026-11-04T22:16:40","date_gmt":"2026-11-04T14:16:40","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/122407.html"},"modified":"2026-11-04T22:16:40","modified_gmt":"2026-11-04T14:16:40","slug":"playwright-%e8%87%aa%e5%8a%a8%e7%ad%89%e5%be%85-ai-%e5%a4%b1%e8%b4%a5%e8%af%8a%e6%96%ad","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/122407.html","title":{"rendered":"Playwright \u81ea\u52a8\u7b49\u5f85 + AI \u5931\u8d25\u8bca\u65ad"},"content":{"rendered":"<p>        \/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/<br \/>\n        #content_views .toc,<br \/>\n        \/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/<br \/>\n        #content_views.markdown_views &gt; p:empty:has(+ .toc),<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty,<br \/>\n        \/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/<br \/>\n        #content_views.htmledit_views #main-toc,<br \/>\n        #content_views.htmledit_views #hr-toc,<br \/>\n        #content_views.htmledit_views p[id*=\\&#8221;-toc\\&#8221;] {<br \/>\n          display: none !important;<br \/>\n        }<br \/>\n        \/* \u76ee\u5f55\u53bb\u6389\u540e\uff0c\u7d27\u8ddf\u7684\u9996\u4e2a\u6807\u9898\u4e0d\u518d\u591a\u51fa\u4e00\u5757\u4e0a\u8fb9\u8ddd *\/<br \/>\n        #content_views.markdown_views &gt; .toc + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + h4,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h4 {<br \/>\n          margin-top: 0 !important;<br \/>\n        }<\/p>\n<p>\u6628\u5929\u90a3\u6279\u7528\u4f8b\u672c\u5730\u5168\u7eff&#xff0c;\u653e\u5230 CI \u4e0a\u5341\u6b21\u7ea2\u4e24\u4e09&#xfffd;&#xfffd;\u3002\u8fd9\u7c7b\u95ee\u9898\u91cc&#xff0c;\u76f8\u5f53\u4e00\u90e8\u5206\u4e0d\u662f\u4ea7\u54c1\u574f\u4e86&#xff0c;\u4e5f\u4e0d\u662f\u7528\u4f8b\u903b\u8f91\u9519\u4e86&#xff0c;\u800c\u662f\u300c\u7b49\u300d\u6ca1\u5199\u5bf9\u3002<\/p>\n<p>\u8fd9\u4e00\u7bc7\u628a\u4e24\u4ef6\u4e8b\u8bb2\u900f&#xff1a;\u600e\u4e48\u7b49&#xff1b;\u7528\u4f8b\u6302\u4e86\u600e\u4e48\u5224\u65ad\u8be5\u627e\u8c01\u3002<\/p>\n<p>\u4ee3\u7801\u5728 Windows \/ Python 3.11.8 \/ Playwright 1.62.0 \/ Chromium 151.0.7922.34 \u4e0a\u5b9e\u8dd1&#xff0c;\u914d\u5957\u811a\u672c examples\/lab\/day36\/&#xff0c;26 passed &#043; 3 failed&#xff08;\u90a3 3 \u4e2a failed \u662f AI \u5047\u4fee\u590d\u6837\u672c&#xff0c;\u8bbe\u8ba1\u5185&#xff09;\u3002<\/p>\n<p>\u672c\u6587\u5f15\u7528\u7684\u5b98\u65b9\u8d44\u6599&#xff1a;Playwright Python \u6587\u6863\u3001\u81ea\u52a8\u7b49\u5f85\u4e0e\u53ef\u64cd\u4f5c\u6027\u3001\u65ad\u8a00\u4e0e\u91cd\u8bd5\u3001WebDriver \u6807\u51c6\u3002<\/p>\n<h3>\u4e00\u3001\u81ea\u52a8\u7b49\u5f85\u7b49\u7684\u662f\u4ec0\u4e48<\/h3>\n<p>\u9875\u9762.goto(\u672c\u5730\u670d\u52a1 &#043; &#034;\/slow\/2001?delay&#061;600&#034;)<br \/>\n\u91d1\u989d &#061; \u9875\u9762.locator(&#039;[data-testid&#061;&#034;order-amount&#034;]&#039;).inner_text()<\/p>\n<p>\u770b\u7740\u50cf\u300c\u76f4\u63a5\u53d6\u300d&#xff0c;\u5b9e\u9645\u4e0a locator \u5728\u64cd\u4f5c\u524d\u4f1a\u7b49\u5230\u5143\u7d20\u8fbe\u5230\u53ef\u64cd\u4f5c\u72b6\u6001&#xff1a;<\/p>\n<table>\n<tr>\u6761\u4ef6\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>\u53ef\u89c1<\/td>\n<td>\u4e0d\u662f display:none&#xff0c;\u4e0d\u662f visibility:hidden<\/td>\n<\/tr>\n<tr>\n<td>\u53ef\u70b9<\/td>\n<td>\u6ca1\u6709\u88ab\u522b\u7684\u5143\u7d20\u6321\u4f4f<\/td>\n<\/tr>\n<tr>\n<td>\u7a33\u5b9a<\/td>\n<td>\u8fde\u7eed\u4e24\u5e27\u7684 bounding box \u4e00\u81f4&#xff0c;\u4e0d\u518d\u79fb\u52a8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b9e\u6d4b\u8fd9\u4e00\u884c\u7b49\u4e86 0.81 \u79d2&#xff08;\u9875\u9762\u5ef6\u65f6 600 \u6beb\u79d2 &#043; \u6d4f\u89c8\u5668\u5f00\u9500&#xff09;&#xff0c;\u4e00\u884c sleep \u90fd\u6ca1\u6709\u3002<\/p>\n<p>locator \u548c get_by_test_id \u8fd9\u7c7b\u5b9a\u4f4d\u5668\u90fd\u81ea\u5e26\u8fd9\u4e2a\u7b49\u5f85&#xff1b;\u800c page.query_selector \u8fd4\u56de\u7684\u662f\u88f8\u5143\u7d20&#xff0c;\u6ca1\u6709\u7b49\u5f85\u3002\u6240\u4ee5\u300c\u7528 locator \u8fd8\u662f\u7528 query_selector\u300d\u4e0d\u53ea\u662f\u98ce\u683c\u95ee\u9898\u3002<\/p>\n<h3>\u4e8c\u3001\u4e09\u79cd\u7b49\u5f85\u5199\u6cd5\u7684\u5b9e\u6d4b\u5bf9\u7167<\/h3>\n<p>\u9875\u9762 \/slow\/2001?delay&#061;600 \u7684\u5185\u5bb9 600 \u6beb\u79d2\u540e\u624d\u63d2\u8fdb\u53bb\u3002<\/p>\n<h4>A. \u81ea\u52a8\u7b49\u5f85<\/h4>\n<p>\u9875\u9762.goto(\u672c\u5730\u670d\u52a1 &#043; &#034;\/slow\/2001?delay&#061;600&#034;)<br \/>\n\u6587\u5b57 &#061; \u9875\u9762.locator(&#039;[data-testid&#061;&#034;order-amount&#034;]&#039;).inner_text()<br \/>\n# 0.81 \u79d2\u540e\u62ff\u5230 &#034;159.80&#034;<\/p>\n<h4>B. sleep<\/h4>\n<p>\u9875\u9762.goto(\u672c\u5730\u670d\u52a1 &#043; &#034;\/slow\/2001?delay&#061;600&#034;)<br \/>\ntime.sleep(0.2)<br \/>\n\u5b58\u5728 &#061; \u9875\u9762.locator(&#039;[data-testid&#061;&#034;order-amount&#034;]&#039;).count()<br \/>\n# 0 \u2014\u2014 \u5143\u7d20\u8fd8\u6ca1\u51fa\u73b0<\/p>\n<p>sleep \u7684\u95ee\u9898\u4e0d\u662f\u300c\u4e0d\u51c6\u300d&#xff0c;\u662f\u6ca1\u6cd5\u9a8c\u8bc1\u3002\u5b83\u548c\u300c\u5143\u7d20\u51fa\u73b0\u4e86\u300d\u4e4b\u95f4\u6ca1\u6709\u4efb\u4f55\u56e0\u679c\u5173\u7cfb\u3002<\/p>\n<h4>C. \u663e\u5f0f\u7b49\u5f85<\/h4>\n<p>\u9875\u9762.goto(\u672c\u5730\u670d\u52a1 &#043; &#034;\/slow\/2001?delay&#061;600&#034;)<br \/>\n\u9875\u9762.locator(&#039;[data-testid&#061;&#034;order-amount&#034;]&#039;).wait_for(state&#061;&#034;visible&#034;, timeout&#061;5000)<\/p>\n<p>\u8d85\u65f6\u8fb9\u754c\u660e\u786e&#xff0c;\u800c\u4e14\u5931\u8d25\u4fe1\u606f\u91cc\u4f1a\u5e26\u4e0a\u300c\u7b49\u7684\u662f\u54ea\u4e2a\u5143\u7d20\u3001\u7b49\u4e86\u591a\u4e45\u300d\u3002<\/p>\n<h4>\u8ba1\u65f6\u8d77\u70b9\u7684\u4e00\u4e2a\u5751<\/h4>\n<p>\u9875\u9762\u91cc\u7684 setTimeout \u662f\u4ece\u9875\u9762\u89e3\u6790\u90a3\u4e00\u523b\u5f00\u59cb\u8ba1\u65f6\u7684\u3002\u5982\u679c\u4ece goto \u8fd4\u56de\u4e4b\u540e\u624d\u5f00\u59cb\u8ba1\u65f6&#xff0c;\u4f1a\u5c11\u7b97\u6389 goto \u672c\u8eab\u82b1\u7684\u65f6\u95f4&#xff1a;<\/p>\n<p>\u5f00\u59cb &#061; time.time()          # \u5fc5\u987b\u5728 goto \u4e4b\u524d<br \/>\n\u9875\u9762.goto(&#8230;)<br \/>\n\u6587\u5b57 &#061; \u9875\u9762.locator(&#8230;).inner_text()<br \/>\n\u8017\u65f6 &#061; time.time() &#8211; \u5f00\u59cb<br \/>\nassert \u8017\u65f6 &gt;&#061; 0.6<\/p>\n<p>\u5b9e\u6d4b&#xff1a;\u53ea\u91cf inner_text \u90a3\u4e00\u6bb5\u662f 0.425 \u79d2&#xff0c;\u4ece goto \u4e4b\u524d\u7b97\u662f 0.63 \u79d2\u3002\u65ad\u8a00 0.6 \u79d2\u65f6\u7528\u9519\u8d77\u70b9&#xff0c;\u5c31\u4f1a\u95f4\u6b47\u6027\u5931\u8d25\u3002<\/p>\n<h3>\u4e09\u3001\u53ef\u91cd\u8bd5\u65ad\u8a00<\/h3>\n<p>from playwright.sync_api import expect<\/p>\n<p>expect(\u9875\u9762.locator(&#039;[data-testid&#061;&#034;order-amount&#034;]&#039;)).to_have_text(&#034;159.80&#034;, timeout&#061;5000)<\/p>\n<p>expect \u4f1a\u53cd\u590d\u68c0\u67e5&#xff0c;\u76f4\u5230\u5bf9\u4e0a\u6216\u8d85\u65f6\u3002\u5bf9\u6bd4\u4e00\u6b21\u6027\u65ad\u8a00&#xff1a;<\/p>\n<p>\u6587\u5b57 &#061; \u9875\u9762.locator(&#039;[data-testid&#061;&#034;order-amount&#034;]&#039;).inner_text(timeout&#061;200)<br \/>\nassert \u6587\u5b57 &#061;&#061; &#034;159.80&#034;<\/p>\n<p>\u533a\u522b\u6709\u4e24\u4e2a&#xff1a;<\/p>\n<li>\u524d\u8005\u4f1a\u7b49&#xff0c;\u540e\u8005\u53d6\u4e00\u6b21\u5c31\u5224\u3002 \u9875\u9762\u6162 600 \u6beb\u79d2\u65f6&#xff0c;\u540e\u8005\u5931\u8d25&#xff0c;\u524d\u8005\u901a\u8fc7\u3002<\/li>\n<li>\u5931\u8d25\u4fe1\u606f\u4e0d\u540c\u3002 expect \u4f1a\u5e26\u4e0a\u5b9e\u9645\u503c\u548c\u671f\u671b\u503c&#xff1a;<\/li>\n<p>Expected: &#034;999.99&#034;<br \/>\nReceived: &#034;159.80&#034;<\/p>\n<p>expect \u4e0d\u53ea\u652f\u6301\u6587\u672c&#xff0c;\u8fd8\u80fd\u7b49\u5c5e\u6027\u3001\u7b49\u53ef\u89c1\u6027\u3001\u7b49\u6570\u91cf&#xff1a;<\/p>\n<p>expect(\u9875\u9762.locator(&#039;[data-testid&#061;&#034;message&#034;]&#039;)).to_have_attribute(&#034;data-result&#034;, &#034;paid&#034;, timeout&#061;5000)<\/p>\n<h3>\u56db\u3001\u8d85\u65f6\u8fb9\u754c<\/h3>\n<p>\u540c\u4e00\u4e2a\u9875\u9762\u3001\u540c\u4e00\u4e2a\u65ad\u8a00&#xff0c;\u53ea\u6709\u8d85\u65f6\u4e0d\u540c&#xff1a;<\/p>\n<table>\n<tr>\u8d85\u65f6\u7ed3\u679c\u8017\u65f6<\/tr>\n<tbody>\n<tr>\n<td>200 \u6beb\u79d2<\/td>\n<td>\u5931\u8d25<\/td>\n<td>0.20 \u79d2<\/td>\n<\/tr>\n<tr>\n<td>5000 \u6beb\u79d2<\/td>\n<td>\u901a\u8fc7<\/td>\n<td>0.81 \u79d2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u300c\u7528\u4f8b\u4e0d\u7a33\u300d\u6709\u65f6\u5019\u53ea\u662f\u8d85\u65f6\u7ed9\u5f97\u4e0d\u5bf9\u3002 \u4f46\u653e\u5bbd\u4e4b\u524d\u5fc5\u987b\u786e\u8ba4\u6839\u56e0\u4e0d\u5728\u670d\u52a1\u7aef\u2014\u2014\u89c1\u7b2c\u516d\u8282\u3002<\/p>\n<p>\u8d85\u65f6\u8be5\u600e\u4e48\u5b9a&#xff1a;\u5148\u91cf&#xff0c;\u518d\u5b9a\u3002 \u8dd1\u4e09\u6b21\u53d6\u6700\u5927\u503c&#xff0c;\u7559 2\u20143 \u500d\u4f59\u91cf&#xff1a;<\/p>\n<p>\u5b9e\u6d4b &#061; []<br \/>\nfor _ in range(3):<br \/>\n    \u5f00\u59cb &#061; time.time()<br \/>\n    \u9875\u9762.goto(&#8230;)<br \/>\n    expect(&#8230;).to_have_text(&#034;159.80&#034;, timeout&#061;5000)<br \/>\n    \u5b9e\u6d4b.append(time.time() &#8211; \u5f00\u59cb)<\/p>\n<p>\u6700\u9ad8 &#061; max(\u5b9e\u6d4b)<br \/>\n\u5b9a\u8d85\u65f6 &#061; int(\u6700\u9ad8 * 1000 * 3)<\/p>\n<h3>\u4e94\u3001\u4e09\u8def\u8bca\u65ad<\/h3>\n<p>\u51c6\u5907\u4e86\u4e00\u4e2a\u9875\u9762&#xff0c;\u5185\u5bb9\u8981\u7b49\u4e00\u4e2a\u63a5\u53e3\u56de\u6765\u624d\u6e32\u67d3&#xff1a;<\/p>\n<table>\n<tr>\u8def\u5f84\u884c\u4e3a<\/tr>\n<tbody>\n<tr>\n<td>\/slowapi\/{id}?delay&#061;600<\/td>\n<td>\u63a5\u53e3\u6162 600 \u6beb\u79d2&#xff0c;\u4f46\u8fd4\u56de 200<\/td>\n<\/tr>\n<tr>\n<td>\/slowapi\/{id}?delay&#061;100&amp;fail&#061;1<\/td>\n<td>\u63a5\u53e3\u8fd4\u56de 500&#xff0c;\u9875\u9762\u663e\u793a\u300c\u52a0\u8f7d\u5931\u8d25\u300d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u73b0\u8c61\u4e00\u6837&#xff1a;\u9875\u9762\u4e0a\u6ca1\u6709\u91d1\u989d\u3002\u6839\u56e0\u5b8c\u5168\u4e0d\u540c\u3002<\/p>\n<h4>\u7b2c\u4e00\u8def&#xff1a;\u7f51\u7edc<\/h4>\n<p>\u8bf7\u6c42 &#061; []<br \/>\n\u9875\u9762.on(&#034;request&#034;, lambda r: \u8bf7\u6c42.append(r.url))<br \/>\n\u54cd\u5e94 &#061; []<br \/>\n\u9875\u9762.on(&#034;response&#034;, lambda r: \u54cd\u5e94.append((r.status, r.url)))<\/p>\n<p>\u9875\u9762.goto(\u672c\u5730\u670d\u52a1 &#043; &#034;\/slowapi\/2001?delay&#061;600&#034;)<\/p>\n<p>\u5b9e\u6d4b&#xff1a;<\/p>\n<p>GET  &#8230;\/slowapi\/2001?delay&#061;600<br \/>\nGET  &#8230;\/api\/sloworder\/2001?delay&#061;600<br \/>\n200  &#8230;\/api\/sloworder\/2001?delay&#061;600<\/p>\n<p>\u8bf7\u6c42\u53d1\u51fa\u53bb\u4e86&#xff0c;\u62ff\u5230\u7684\u662f 200\u3002\u6162&#xff0c;\u4f46\u4e0d\u662f\u9519\u3002<\/p>\n<p>\u26a0\ufe0f \u76d1\u542c\u5668\u5fc5\u987b\u5728 goto \u4e4b\u524d\u6ce8\u518c\u3002 \u5199\u5728\u540e\u9762\u4e00\u4e2a\u8bf7\u6c42\u90fd\u6536\u4e0d\u5230\u2014\u2014\u9875\u9762\u91cc\u7684\u8bf7\u6c42\u65e9\u5c31\u53d1\u5b8c\u4e86\u3002<\/p>\n<h4>\u7b2c\u4e8c\u8def&#xff1a;\u9875\u9762<\/h4>\n<p>\u622a\u56fe &#061; \u9875\u9762.screenshot()<br \/>\n\u5360\u4f4d &#061; \u9875\u9762.locator(&#039;[data-testid&#061;&#034;placeholder&#034;]&#039;).count()<br \/>\n\u9519\u8bef &#061; \u9875\u9762.locator(&#039;[data-testid&#061;&#034;load-error&#034;]&#039;).count()<\/p>\n<p>\u6162\u63a5\u53e3\u573a\u666f&#xff1a;\u5360\u4f4d 1\u3001\u9519\u8bef 0 \u2014\u2014 \u5361\u5728\u300c\u52a0\u8f7d\u4e2d\u300d\u3002\u63a5\u53e3\u62a5\u9519\u573a\u666f&#xff1a;\u5360\u4f4d 0\u3001\u9519\u8bef 1 \u2014\u2014 \u9875\u9762\u81ea\u5df1\u663e\u793a\u4e86\u5931\u8d25\u3002<\/p>\n<p>\u8fd9\u4e00\u8def\u80fd\u5206\u51fa\u300c\u8fd8\u6ca1\u52a0\u8f7d\u5b8c\u300d\u548c\u300c\u52a0\u8f7d\u51fa\u9519\u4e86\u300d\u3002<\/p>\n<h4>\u7b2c\u4e09\u8def&#xff1a;\u4e1a\u52a1\u72b6\u6001<\/h4>\n<p>\u63a5\u53e3\u6570\u636e &#061; requests.get(\u672c\u5730\u670d\u52a1 &#043; &#034;\/api\/orders\/2001&#034;).json()<br \/>\nassert \u63a5\u53e3\u6570\u636e[&#034;status&#034;] &#061;&#061; &#034;PAID&#034;<br \/>\nassert \u63a5\u53e3\u6570\u636e[&#034;amount&#034;] &#061;&#061; &#034;199.80&#034;<\/p>\n<p>\u4e1a\u52a1\u6570\u636e\u5b8c\u5168\u6b63\u5e38\u3002\u6240\u4ee5\u95ee\u9898\u4e0d\u5728\u6570\u636e&#xff0c;\u5728\u901f\u5ea6\u6216\u9519\u8bef&#xff0c;\u4e0d\u5728\u6d4b\u8bd5\u811a\u672c\u3002<\/p>\n<p>\u4e09\u8def\u8d70\u5b8c\u624d\u80fd\u4e0b\u7ed3\u8bba&#xff1a;\u300c\u8fd9\u662f\u670d\u52a1\u7aef\u6162\u300d&#xff0c;\u800c\u4e0d\u662f\u300c\u7528\u4f8b\u5199\u5f97\u4e0d\u597d\u300d\u3002<\/p>\n<h3>\u516d\u3001\u7b49\u5bf9\u5143\u7d20&#xff0c;\u624d\u80fd\u62a5\u5bf9\u539f\u56e0<\/h3>\n<p>\u540c\u4e00\u4e2a\u5931\u8d25&#xff0c;\u4e24\u79cd\u7b49\u6cd5&#xff1a;<\/p>\n<p># \u7b49\u6cd5\u4e00&#xff1a;\u53ea\u7b49\u91d1\u989d<br \/>\n\u9875\u9762.locator(&#039;[data-testid&#061;&#034;order-amount&#034;]&#039;).inner_text(timeout&#061;2000)<br \/>\n# Timeout 2000ms exceeded<\/p>\n<p># \u7b49\u6cd5\u4e8c&#xff1a;\u7b49\u300c\u91d1\u989d\u300d\u6216\u300c\u52a0\u8f7d\u5931\u8d25\u300d\u5176\u4e2d\u4e00\u4e2a<br \/>\n\u9875\u9762.locator(&#039;[data-testid&#061;&#034;loaded-card&#034;], [data-testid&#061;&#034;load-error&#034;]&#039;).first.wait_for(<br \/>\n    state&#061;&#034;visible&#034;, timeout&#061;2000)<br \/>\n\u9875\u9762.locator(&#039;[data-testid&#061;&#034;load-error&#034;]&#039;).inner_text()<br \/>\n# \u52a0\u8f7d\u5931\u8d25&#xff1a;http 500<\/p>\n<p>\u7b49\u6cd5\u4e00\u544a\u8bc9\u4f60\u300c\u91d1\u989d\u6ca1\u51fa\u73b0\u300d&#xff0c;\u7b49\u6cd5\u4e8c\u544a\u8bc9\u4f60\u300c\u63a5\u53e3\u8fd4\u56de\u4e86 500\u300d\u3002<\/p>\n<h4>\u4e00\u4e2a\u66f4\u9634\u9669\u7684\u5751<\/h4>\n<p>\u7b49\u6cd5\u4e00\u7684\u62a5\u9519\u5168\u6587\u662f&#xff1a;<\/p>\n<p>Locator.inner_text: Timeout 5000ms exceeded.<br \/>\nCall log:<br \/>\n  &#8211; waiting for locator(&#034;[data-testid&#061;\\\\&#034;order-amount\\\\&#034;]&#034;)<\/p>\n<p>\u8fd9\u91cc\u7684 500 \u662f 5000ms \u7684\u4e00\u90e8\u5206&#xff0c;\u4e0d\u662f HTTP \u72b6\u6001\u7801\u3002 \u62ff\u5b83\u5224\u65ad\u300c\u63a5\u53e3\u662f\u4e0d\u662f\u8fd4\u56de\u4e86 500\u300d\u4f1a\u5f97\u51fa\u76f8\u53cd\u7684\u7ed3\u8bba\u3002<\/p>\n<p>\u914d\u5957\u811a\u672c 05_ai_fix.py \u91cc\u4e13\u95e8\u4e3a\u8fd9\u4e00\u70b9\u5199\u4e86\u4e00\u6761\u65ad\u8a00\u3002<\/p>\n<h3>\u4e03\u3001AI \u4fee\u4e0d\u7a33\u5b9a\u7528\u4f8b\u7684\u4e09\u79cd\u5047\u4fee\u590d<\/h3>\n<table>\n<tr>\u5b83\u7684\u6539\u6cd5\u4e3a\u4ec0\u4e48\u9519\u5b9e\u6d4b<\/tr>\n<tbody>\n<tr>\n<td>\u8d85\u65f6\u4ece 200 \u6beb\u79d2\u653e\u5927\u5230 5 \u79d2<\/td>\n<td>\u63a5\u53e3 100 \u6beb\u79d2\u5c31\u8fd4\u56de 500&#xff0c;\u7b49\u518d\u4e45\u4e5f\u4e0d\u4f1a\u53d8\u597d<\/td>\n<td>\u767d\u7b49 5.00 \u79d2&#xff0c;\u62a5\u9519\u91cc\u6ca1\u6709\u6839\u56e0<\/td>\n<\/tr>\n<tr>\n<td>try\/except \u5305\u4f4f&#xff0c;\u5931\u8d25\u4e5f\u5f53\u901a\u8fc7<\/td>\n<td>CI \u7eff\u4e86&#xff0c;\u95ee\u9898\u8fd8\u5728<\/td>\n<td>\u7528\u4f8b\u300c\u901a\u8fc7\u300d&#xff0c;\u4f46\u63a5\u53e3\u660e\u660e 500<\/td>\n<\/tr>\n<tr>\n<td>\u65ad\u8a00\u4ece\u300c\u7b49\u4e8e 159.80\u300d\u5f31\u5316\u6210\u300c\u5143\u7d20\u5b58\u5728\u300d<\/td>\n<td>\u65ad\u8a00\u6ca1\u4e86<\/td>\n<td>\u9875\u9762\u663e\u793a 88.88 \u4e5f\u7167\u6837\u901a\u8fc7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7b2c\u4e09\u79cd\u6211\u5b9e\u6d4b\u8fc7&#xff1a;\u8ba9\u9875\u9762\u663e\u793a\u4e00\u4e2a\u9519\u7684\u91d1\u989d 88.88&#xff0c;\u5f31\u65ad\u8a00\u7167\u6837\u901a\u8fc7&#xff0c;\u5f3a\u65ad\u8a00\u7acb\u523b\u6293\u5230\u3002<\/p>\n<h4>\u5ba1\u67e5\u89c4\u5219<\/h4>\n<p>\u5224\u65ad AI \u7ed9\u7684\u662f\u4e0d\u662f\u5047\u4fee\u590d&#xff0c;\u770b\u4e09\u4e2a\u95ee\u9898&#xff1a;<\/p>\n<li>\u6839\u56e0\u662f\u4ec0\u4e48&#xff1f; \u4e0d\u662f\u300c\u8d85\u65f6\u4e0d\u591f\u300d\u3002<\/li>\n<li>\u6539\u5b8c\u4e4b\u540e&#xff0c;\u5931\u8d25\u65f6\u8fd8\u80fd\u770b\u51fa\u539f\u56e0\u5417&#xff1f; \u62a5\u9519\u91cc\u6709\u6ca1\u6709\u771f\u6b63\u7684\u539f\u56e0\u3002<\/li>\n<li>\u65ad\u8a00\u53d8\u5f3a\u4e86\u8fd8\u662f\u53d8\u5f31\u4e86&#xff1f; \u53d8\u5f31\u7684\u4e00\u5f8b\u6253\u56de\u3002<\/li>\n<p>\u7b2c\u4e09\u6761\u6700\u5bb9\u6613\u67e5\u4e5f\u6700\u6709\u6548\u3002\u914d\u5957\u811a\u672c 07_answer.py \u7684\u7ec3\u4e60\u56db\u628a\u524d\u4e24\u6761\u5199\u6210\u4e86\u53ef\u6267\u884c\u7684\u5ba1\u67e5\u51fd\u6570\u3002<\/p>\n<h3>\u516b\u3001\u987a\u5e26\u5bf9\u6bd4\u4e00\u4e0b\u4e24\u5929\u7684\u7b49\u5f85\u6a21\u578b<\/h3>\n<p>Day35 \u7528 Selenium&#xff0c;\u4eca\u5929\u7528 Playwright\u3002\u4e24\u5957\u6a21\u578b\u5dee\u522b\u5f88\u5927&#xff0c;\u653e\u4e00\u8d77\u770b\u66f4\u6e05\u695a\u3002<\/p>\n<table>\n<tr>Selenium&#xff08;Day35&#xff09;Playwright&#xff08;\u4eca\u5929&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u7b49\u5143\u7d20\u51fa\u73b0<\/td>\n<td>WebDriverWait(driver, t).until(EC.presence_of_element_located(&#8230;))<\/td>\n<td>locator.inner_text() \u81ea\u52a8\u7b49<\/td>\n<\/tr>\n<tr>\n<td>\u7b49\u5143\u7d20\u53ef\u70b9<\/td>\n<td>\u8981\u989d\u5916\u7528 EC.element_to_be_clickable<\/td>\n<td>\u9ed8\u8ba4\u5c31\u7b49\u5230\u53ef\u64cd\u4f5c<\/td>\n<\/tr>\n<tr>\n<td>\u7b49\u6587\u5b57\u51fa\u73b0<\/td>\n<td>\u81ea\u5df1\u5199\u8c13\u8bcd&#xff08;text_to_be_present_in_element \u5728 4.x \u91cc\u662f\u5b50\u4e32\u5339\u914d&#xff09;<\/td>\n<td>expect(&#8230;).to_have_text(&#8230;) \u53ef\u91cd\u8bd5<\/td>\n<\/tr>\n<tr>\n<td>\u7b49\u72b6\u6001\u53d8\u5316<\/td>\n<td>\u81ea\u5df1\u8f6e\u8be2<\/td>\n<td>expect(&#8230;).to_have_attribute(&#8230;)<\/td>\n<\/tr>\n<tr>\n<td>\u8d85\u65f6\u63a7\u5236<\/td>\n<td>\u6bcf\u6b21\u8c03\u7528\u4f20 timeout&#061;<\/td>\n<td>\u6bcf\u6b21\u8c03\u7528\u4f20 timeout&#061;&#xff0c;\u4e5f\u53ef\u5168\u5c40 expect.configure<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Selenium \u7684\u7b49\u5f85\u662f\u300c\u4f60\u5199\u51fa\u6765\u7684\u300d&#xff0c;Playwright \u7684\u7b49\u5f85\u662f\u300c\u9ed8\u8ba4\u5c31\u5728\u7684\u300d\u3002<\/p>\n<p>\u8fd9\u4e0d\u662f\u8c01\u66f4\u597d\u7684\u95ee\u9898&#xff0c;\u662f\u8bbe\u8ba1\u53d6\u5411\u4e0d\u540c&#xff1a;Selenium \u66f4\u63a5\u8fd1 W3C \u539f\u59cb\u89c4\u8303&#xff08;\u7b49\u5f85\u662f\u663e\u5f0f\u7684\u4e00\u6b65&#xff09;&#xff0c;Playwright \u628a\u7b49\u5f85\u505a\u8fdb\u4e86\u6bcf\u4e2a\u64cd\u4f5c\u91cc\u3002\u524d\u8005\u5570\u55e6\u4f46\u53ef\u89e3\u91ca&#xff0c;\u540e\u8005\u7b80\u6d01\u4f46\u8981\u6e05\u695a\u5b83\u7684\u8fb9\u754c\u2014\u2014\u6bd4\u5982 page.query_selector \u5c31\u6ca1\u6709\u7b49\u5f85\u3002<\/p>\n<p>Day35 \u90a3\u4e2a wait_for_text \u81ea\u5df1\u5199\u8c13\u8bcd\u7684\u5751&#xff08;\u56e0\u4e3a Selenium 4.x \u6539\u4e86\u8bed\u4e49&#xff09;&#xff0c;\u5728 Playwright \u8fd9\u8fb9\u4e0d\u5b58\u5728&#xff1a;expect \u7684\u91cd\u8bd5\u662f\u5185\u7f6e\u7684\u3002<\/p>\n<h3>\u4e5d\u3001\u8ba9\u5931\u8d25\u7684\u7528\u4f8b\u81ea\u5df1\u5e26\u8bc1\u636e<\/h3>\n<p>\u4e09\u8def\u8bca\u65ad\u662f\u4eba\u624b\u5de5\u505a\u7684\u3002\u53ef\u4ee5\u628a\u5b83\u505a\u6210\u7528\u4f8b\u7684\u4e00\u90e8\u5206\u2014\u2014\u5931\u8d25\u65f6\u81ea\u52a8\u628a\u8bc1\u636e\u9644\u5728\u62a5\u9519\u4fe1\u606f\u91cc&#xff1a;<\/p>\n<p>def test_\u4e0d\u7a33\u5b9a\u7684\u7528\u4f8b\u8981\u80fd\u590d\u73b0\u4e5f\u8981\u80fd\u5b9a\u4f4d(\u9875\u9762, \u672c\u5730\u670d\u52a1):<br \/>\n    # \u76d1\u542c\u5668\u8981\u5728 goto \u4e4b\u524d\u6ce8\u518c<br \/>\n    \u8bf7\u6c42 &#061; []<br \/>\n    \u9875\u9762.on(&#034;request&#034;, lambda r: \u8bf7\u6c42.append(r.url))<\/p>\n<p>    \u9875\u9762.goto(\u672c\u5730\u670d\u52a1 &#043; &#034;\/slowapi\/2001?delay&#061;100&amp;fail&#061;1&#034;)<\/p>\n<p>    try:<br \/>\n        \u9875\u9762.locator(&#039;[data-testid&#061;&#034;loaded-card&#034;], [data-testid&#061;&#034;load-error&#034;]&#039;).first.wait_for(<br \/>\n            state&#061;&#034;visible&#034;, timeout&#061;5000)<br \/>\n        \u9875\u9762\u9519\u8bef &#061; \u9875\u9762.locator(&#039;[data-testid&#061;&#034;load-error&#034;]&#039;).inner_text()<br \/>\n        \u76f8\u5173\u8bf7\u6c42 &#061; [u for u in \u8bf7\u6c42 if &#034;\/api\/sloworder\/&#034; in u]<br \/>\n        raise AssertionError(<br \/>\n            f&#034;\u9875\u9762\u52a0\u8f7d\u5931\u8d25&#xff5c;\u9875\u9762\u63d0\u793a&#xff1a;{\u9875\u9762\u9519\u8bef}&#xff5c;\u76f8\u5173\u8bf7\u6c42&#xff1a;{\u76f8\u5173\u8bf7\u6c42}&#034;)<br \/>\n    except AssertionError as e:<br \/>\n        \u4fe1\u606f &#061; str(e)<\/p>\n<p>    assert &#034;500&#034; in \u4fe1\u606f<br \/>\n    assert &#034;\/api\/sloworder\/&#034; in \u4fe1\u606f, &#034;\u5931\u8d25\u4fe1\u606f\u91cc\u5e94\u8be5\u5e26\u4e0a\u76f8\u5173\u8bf7\u6c42\u5730\u5740&#034;<\/p>\n<p>\u5931\u8d25\u4fe1\u606f\u957f\u8fd9\u6837&#xff1a;<\/p>\n<p>\u9875\u9762\u52a0\u8f7d\u5931\u8d25&#xff5c;\u9875\u9762\u63d0\u793a&#xff1a;\u52a0\u8f7d\u5931\u8d25&#xff1a;http 500&#xff5c;\u76f8\u5173\u8bf7\u6c42&#xff1a;[&#039;http:\/\/127.0.0.1:xxxx\/api\/sloworder\/2001?delay&#061;100&amp;fail&#061;1&#039;]<\/p>\n<p>\u770b\u5230\u8fd9\u4e00\u884c&#xff0c;\u4f60\u4e0d\u7528\u518d\u6253\u5f00\u6d4f\u89c8\u5668\u3001\u4e5f\u4e0d\u7528\u91cd\u65b0\u8dd1\u4e00\u904d&#xff0c;\u5c31\u77e5\u9053\u662f\u54ea\u4e2a\u63a5\u53e3\u3001\u62a5\u7684\u662f\u4ec0\u4e48\u3002CI \u7684\u65e5\u5fd7\u5c31\u662f\u73b0\u573a\u3002<\/p>\n<p>\u8fd9\u4e2a\u6a21\u5f0f\u503c\u5f97\u62bd\u8c61\u6210\u4e00\u4e2a\u5de5\u5177\u51fd\u6570&#xff1a;\u628a\u300c\u6536\u96c6\u8bc1\u636e\u300d\u548c\u300c\u505a\u65ad\u8a00\u300d\u5206\u5f00&#xff0c;\u65ad\u8a00\u5931\u8d25\u65f6\u7edf\u4e00\u9644\u5e26\u8bc1\u636e\u3002\u914d\u5957\u811a\u672c 06_fixed.py \u91cc\u7ed9\u4e86\u4e00\u4e2a\u96cf\u5f62\u3002<\/p>\n<p>\u8fd8\u6709\u4e00\u70b9\u503c\u5f97\u5355\u72ec\u8bf4&#xff1a;\u8bc1\u636e\u8981\u6536\u96c6\u5728 goto \u4e4b\u524d\u5c31\u5f00\u59cb\u3002 \u9875\u9762\u91cc\u7684\u8bf7\u6c42\u662f\u6253\u5f00\u9875\u9762\u90a3\u4e00\u523b\u5c31\u53d1\u51fa\u7684&#xff0c;\u76d1\u542c\u5668\u6ce8\u518c\u665a\u4e86\u5c31\u4ec0\u4e48\u90fd\u6536\u4e0d\u5230\u2014\u2014\u6211\u7b2c\u4e00\u7248\u5c31\u8e29\u4e86\u8fd9\u4e2a\u5751&#xff0c;\u67e5\u4e86\u534a\u5929\u624d\u53d1\u73b0\u4e0d\u662f\u4ee3\u7801\u903b\u8f91\u95ee\u9898&#xff0c;\u662f\u81ea\u5df1\u628a\u8bc1\u636e\u4e22\u4e86\u3002<\/p>\n<h4>\u8bc1\u636e\u8981\u6536\u96c6\u54ea\u4e9b<\/h4>\n<p>\u6309\u4eca\u5929\u7684\u7ecf\u9a8c&#xff0c;\u4e09\u6837\u6700\u6709\u7528&#xff1a;<\/p>\n<table>\n<tr>\u8bc1\u636e\u80fd\u56de\u7b54\u4ec0\u4e48<\/tr>\n<tbody>\n<tr>\n<td>\u8bf7\u6c42\u5217\u8868 &#043; \u72b6\u6001\u7801<\/td>\n<td>\u662f\u6839\u672c\u6ca1\u53d1\u51fa\u53bb&#xff0c;\u8fd8\u662f\u53d1\u51fa\u53bb\u88ab\u62d2\u4e86<\/td>\n<\/tr>\n<tr>\n<td>\u9875\u9762\u81ea\u5df1\u7684\u9519\u8bef\u63d0\u793a<\/td>\n<td>\u670d\u52a1\u7aef\u5df2\u7ecf\u62a5\u4e86\u4ec0\u4e48&#xff08;\u6bd4\u5ba2\u6237\u7aef\u62a5\u9519\u51c6&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u622a\u56fe<\/td>\n<td>\u8089\u773c\u80fd\u786e\u8ba4\u5f53\u65f6\u957f\u4ec0\u4e48\u6837<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7b2c\u4e09\u6837\u5728 Day37 \u4f1a\u5c55\u5f00\u8bb2\u2014\u2014\u5b83\u4e0d\u53ea\u662f\u7ed9\u4eba\u770b\u7684&#xff0c;\u8fd8\u662f\u89c6\u89c9\u6d4b\u8bd5\u7684\u8f93\u5165\u3002<\/p>\n<h3>\u5341\u3001\u56db\u9053\u7ec3\u4e60<\/h3>\n<p>\u7b54\u6848\u5728 07_answer.py&#xff0c;4 passed\u3002<\/p>\n<p>\u7ec3\u4e60\u4e00&#xff1a;\u7b49\u5bf9\u5143\u7d20\u624d\u80fd\u62a5\u5bf9\u539f\u56e0\u3002 \u628a\u53ea\u7b49\u91d1\u989d\u6539\u6210\u7b49\u300c\u91d1\u989d\u6216\u9519\u8bef\u300d&#xff0c;\u65ad\u8a00\u5931\u8d25\u4fe1\u606f\u91cc\u51fa\u73b0 http 500&#xff0c;\u4e14\u8017\u65f6 &lt; 2 \u79d2\u3002<\/p>\n<p>\u7ec3\u4e60\u4e8c&#xff1a;\u8d85\u65f6\u6309\u5b9e\u6d4b\u5b9a\u3002 \u8dd1\u4e09\u6b21\u53d6\u6700\u5927\u503c&#xff0c;\u7559 3 \u500d\u4f59\u91cf&#xff0c;\u5e76\u65ad\u8a00\u8d85\u65f6\u4e0d\u8d85\u8fc7 30 \u79d2&#xff08;\u8d85\u65f6\u592a\u5927\u4f1a\u63a9\u76d6\u771f\u95ee\u9898&#xff09;\u3002<\/p>\n<p>\u7ec3\u4e60\u4e09&#xff1a;\u5931\u8d25\u4fe1\u606f\u8981\u80fd\u5b9a\u4f4d\u3002 \u65ad\u8a00\u6d88\u606f\u91cc\u540c\u65f6\u5e26\u4e0a&#xff1a;\u671f\u671b\u4ec0\u4e48\u3001\u5b9e\u9645\u4ec0\u4e48\u3001\u8bf7\u6c42\u53d1\u5230\u54ea\u53bb\u4e86\u3002<\/p>\n<p>\u7ec3\u4e60\u56db&#xff1a;\u8bc6\u522b\u5047\u4fee\u590d\u3002 \u5199\u4e00\u4e2a \u5ba1\u67e5(\u6e90\u7801) \u51fd\u6570&#xff0c;\u8fd4\u56de\u95ee\u9898\u5217\u8868&#xff0c;\u81f3\u5c11\u80fd\u67e5\u51fa\u300c\u65ad\u8a00\u88ab\u5f31\u5316\u300d\u548c\u300c\u8d85\u65f6\u65e0\u4f9d\u636e\u653e\u5927\u300d\u3002<\/p>\n<h3>\u5341\u4e00\u3001\u4eca\u5929\u6ca1\u505a\u7684<\/h3>\n<ul>\n<li>\u6ca1\u505a Playwright \u7684 trace&#xff08;page.tracing&#xff09;\u5f55\u5236&#xff0c;\u53ea\u7528\u4e86 page.on(&#034;request&#034;) \u548c page.screenshot()<\/li>\n<li>\u6ca1\u505a Playwright \u81ea\u5df1\u7684 expect \u7684\u8f6f\u91cd\u8bd5\u4e0e\u786c\u8d85\u65f6\u533a\u5206&#xff08;expect.configure&#xff09;<\/li>\n<li>\u6ca1\u505a\u91cd\u8bd5\u673a\u5236&#xff08;&#8211;retries&#xff09;\u548c CI \u96c6\u6210<\/li>\n<li>\u6ca1\u7528 Playwright \u7684 page.route \u505a Mock&#xff08;\u90a3\u662f Day29 \u7684 Mock \u4e13\u9898&#xff09;<\/li>\n<li>Playwright \u7684 headless shell \u6ca1\u88c5\u5b8c&#xff0c;\u7528\u7684\u662f\u5b8c\u6574 Chromium&#xff1b;playwright install chromium \u8dd1\u901a\u9700\u8981\u7b49\u90a3\u4e2a 191MB \u7684\u5305\u4e0b\u5b8c<\/li>\n<\/ul>\n<p>\u4e0b\u4e00\u6b65\u662f Day37\u300aWeb \u89c6\u89c9\u6d4b\u8bd5 &#043; AI \u622a\u56fe\u6bd4\u5bf9\u300b&#xff0c;\u8bb2\u600e\u4e48\u7528\u622a\u56fe\u5224\u65ad\u300c\u957f\u5f97\u5bf9\u4e0d\u5bf9\u300d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,50,139,137,210],"topic":[],"class_list":["post-122407","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-50","tag-139","tag-137","tag-210"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Playwright \u81ea\u52a8\u7b49\u5f85 + AI \u5931\u8d25\u8bca\u65ad - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/122407.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Playwright \u81ea\u52a8\u7b49\u5f85 + AI \u5931\u8d25\u8bca\u65ad - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/122407.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-04T14:16:40+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/122407.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/122407.html\",\"name\":\"Playwright \u81ea\u52a8\u7b49\u5f85 + AI \u5931\u8d25\u8bca\u65ad - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-04T14:16:40+00:00\",\"dateModified\":\"2026-11-04T14:16:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/122407.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/122407.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/122407.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Playwright \u81ea\u52a8\u7b49\u5f85 + AI \u5931\u8d25\u8bca\u65ad\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Playwright \u81ea\u52a8\u7b49\u5f85 + AI \u5931\u8d25\u8bca\u65ad - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/122407.html","og_locale":"zh_CN","og_type":"article","og_title":"Playwright \u81ea\u52a8\u7b49\u5f85 + AI \u5931\u8d25\u8bca\u65ad - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content","og_url":"https:\/\/www.wsisp.com\/helps\/122407.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-04T14:16:40+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/122407.html","url":"https:\/\/www.wsisp.com\/helps\/122407.html","name":"Playwright \u81ea\u52a8\u7b49\u5f85 + AI \u5931\u8d25\u8bca\u65ad - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-04T14:16:40+00:00","dateModified":"2026-11-04T14:16:40+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/122407.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/122407.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/122407.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Playwright \u81ea\u52a8\u7b49\u5f85 + AI \u5931\u8d25\u8bca\u65ad"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/122407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=122407"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/122407\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=122407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=122407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=122407"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=122407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}