{"id":53377,"date":"2024-12-03T11:43:08","date_gmt":"2024-12-03T03:43:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53377\/"},"modified":"2024-12-03T11:43:08","modified_gmt":"2024-12-03T03:43:08","slug":"%e7%8e%b0%e4%bb%a3%e4%bd%8e%e4%bb%a3%e7%a0%81%e6%b5%8b%e8%af%95%e5%b9%b3%e5%8f%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53377\/","title":{"rendered":"\u73b0\u4ee3\u4f4e\u4ee3\u7801\u6d4b\u8bd5\u5e73\u53f0"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u73b0\u4ee3\u4f4e\u4ee3\u7801\u6d4b\u8bd5\u5e73\u53f0<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span>    <\/p>\n<p>\u6587\u7ae0\u5c0f\u767d\u4e00\u679a\uff0c\u6b63\u5728\u4e0d\u65ad\u5b66\u4e60\u79ef\u7d2f\u77e5\u8bc6\uff0c\u73b0\u5c06\u5b66\u4e60\u5230\u7684\u77e5\u8bc6\u8bb0\u5f55\u4e00\u4e0b\uff0c\u4e5f\u662f\u5c06\u6211\u7684\u6240\u5f97\u5206\u4eab\u7ed9\u5927\u5bb6\uff01\u800c\u4eca\u5929\u8fd9\u7bc7\u6587\u7ae0\u300a\u73b0\u4ee3\u4f4e\u4ee3\u7801\u6d4b\u8bd5\u5e73\u53f0\u300b\u5e26\u5927\u5bb6\u6765\u4e86\u89e3\u4e00\u4e0b##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<p><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241129\/17328848826749b992c711d.jpg\" class=\"aligncenter\" title=\"\u73b0\u4ee3\u4f4e\u4ee3\u7801\u6d4b\u8bd5\u5e73\u53f0\u63d2\u56fe\" alt=\"\u73b0\u4ee3\u4f4e\u4ee3\u7801\u6d4b\u8bd5\u5e73\u53f0\u63d2\u56fe\" \/><\/p>\n<p>\u901a\u8fc7\u667a\u80fd\u5143\u7d20\u8bc6\u522b\u8fdb\u884c\u53ef\u89c6\u5316\u8bb0\u5f55\u548c\u56de\u653e<br \/> \u73b0\u4ee3\u5de5\u5177\u73b0\u5728\u4f7f\u7528\u4eba\u5de5\u667a\u80fd\u6bd4\u4f20\u7edf\u9009\u62e9\u5668\u66f4\u53ef\u9760\u5730\u8bc6\u522b\u5143\u7d20\u3002\u4f8b\u5982\uff1a<br \/> \u87d2\u86c7<\/p>\n<pre># traditional explicit selector approach\nbutton = driver.find_element(by.xpath, \"\/\/button[@id='submit-btn' or contains(@class, 'submit')]\")\n\n# modern low-code equivalent (automatically generates multiple fallback strategies)\nclick(\"submit\") # the tool automatically tries:\n                # - text content matching\n                # - partial class matching\n                # - visual recognition\n                # - nearby element context\n                # - element hierarchy\n<\/pre>\n<p>\u81ea\u7136\u8bed\u8a00\u6d4b\u8bd5\u7528\u4f8b<br \/> \u50cf cucumber \u8fd9\u6837\u7684\u5de5\u5177\u5df2\u7ecf\u53d1\u5c55\u5230\u652f\u6301\u66f4\u76f4\u89c2\u7684\u6d4b\u8bd5\u7f16\u5199\uff1a<br \/> \u5c0f\u9ec4\u74dc<\/p>\n<pre># modern bdd test scenario\nfeature: user authentication\n  scenario: successful login\n    given i am on the login page\n    when i enter \"test@example.com\" into the email field\n    and i enter \"password123\" into the password field\n    and i click the \"sign in\" button\n    then i should see the dashboard\n    and i should see \"welcome back\" message\n\n# the low-code platform automatically generates the underlying code:\nasync function logintest() {\n    await page.navigate('login');\n    await page.fill('[data-test=\"email\"]', 'test@example.com');\n    await page.fill('[data-test=\"password\"]', 'password123');\n    await page.click('button:has-text(\"sign in\")');\n    await expect(page).tohaveurl(\/.*dashboard\/);\n    await expect(page.locator('.welcome-message')).tocontaintext('welcome back');\n}\n<\/pre>\n<p>\u667a\u80fd\u6d4b\u8bd5\u7ef4\u62a4<br \/> \u73b0\u4ee3\u5e73\u53f0\u5177\u6709\u81ea\u6211\u4fee\u590d\u529f\u80fd\uff1a<br \/> javascript<\/p>\n<pre>\/\/ configuration for smart element detection\n{\n    \"elementdetection\": {\n        \"primary\": \"id\",\n        \"fallback\": [\"css\", \"xpath\", \"text\"],\n        \"smartlocatorstrategy\": {\n            \"enabled\": true,\n            \"maxattempts\": 3,\n            \"timeout\": 10000,\n            \"healingreport\": true\n        }\n    }\n}\n\n\/\/ the platform automatically maintains tests when ui changes:\nawait click(\"login\")  \/\/ if the button changes, the tool tries:\n                     \/\/ 1. original selector\n                     \/\/ 2. similar elements nearby\n                     \/\/ 3. elements with similar text\n                     \/\/ 4. elements in similar position\n<\/pre>\n<p>\u8de8\u5e73\u53f0\u6d4b\u8bd5\u91cd\u7528<br \/> \u73b0\u4ee3\u4f4e\u4ee3\u7801\u5e73\u53f0\u5141\u8bb8\u5728\u4e0d\u540c\u5e73\u53f0\u4e0a\u8fd0\u884c\u76f8\u540c\u7684\u6d4b\u8bd5\uff1a<br \/> yaml<\/p>\n<pre># test configuration\ntest:\n  name: \"login flow\"\n  platforms:\n    - web:\n        browsers: [\"chrome\", \"firefox\", \"safari\"]\n    - mobile:\n        devices: [\"ios\", \"android\"]\n    - desktop:\n        apps: [\"windows\", \"mac\"]\n\n  actions:\n    - input: \n        field: \"username\"\n        value: \"{test.data.username}\"\n    - input:\n        field: \"password\"\n        value: \"{test.data.password}\"\n    - click:\n        element: \"login\"\n    - verify:\n        element: \"dashboard\"\n        state: \"visible\"\n<\/pre>\n<p>\u5185\u7f6e api \u96c6\u6210\u6d4b\u8bd5<br \/> \u73b0\u4ee3\u4f4e\u4ee3\u7801\u5e73\u53f0\u65e0\u7f1d\u7ed3\u5408 ui \u548c api \u6d4b\u8bd5\uff1a<br \/> \u87d2\u86c7<\/p>\n<pre># mixed ui and api test flow\ntest_flow = {\n    \"steps\": [\n        # ui step\n        {\"action\": \"click\", \"element\": \"create_account\"},\n\n        # api validation\n        {\"action\": \"api_check\",\n         \"endpoint\": \"\/api\/user\",\n         \"method\": \"get\",\n         \"validate\": {\n             \"status\": 200,\n             \"response.username\": \"${created_username}\"\n         }},\n\n        # continue ui flow\n        {\"action\": \"verify\", \"element\": \"welcome_message\"}\n    ]\n}\n<\/pre>\n<p>\u667a\u80fd\u6d4b\u8bd5\u6570\u636e\u7ba1\u7406\uff1a<br \/> javascript<\/p>\n<pre>\/\/ Modern data-driven test configuration\n{\n    \"testData\": {\n        \"source\": \"dynamic\",\n        \"generator\": {\n            \"type\": \"smart\",\n            \"rules\": {\n                \"email\": \"valid_email\",\n                \"phone\": \"valid_phone\",\n                \"address\": \"valid_address\"\n            },\n            \"relationships\": {\n                \"shipping_zip\": \"match_billing_country\"\n            }\n        }\n    }\n}\n<\/pre>\n<p>\u73b0\u4ee3\u4f4e\u4ee3\u7801\u5e73\u53f0\u7684\u4e3b\u8981\u4f18\u52bf\u662f\u5b83\u4eec\u53ef\u4ee5\u5728\u53ef\u89c6\u5316\u754c\u9762\u80cc\u540e\u5904\u7406\u6240\u6709\u8fd9\u4e9b\u590d\u6742\u6027\uff0c\u540c\u65f6\u4ecd\u7136\u5141\u8bb8\u6d4b\u8bd5\u4eba\u5458\u5728\u9700\u8981\u65f6\u81ea\u5b9a\u4e49\u5e95\u5c42\u4ee3\u7801\u3002 <\/p>\n<p>\u7406\u8bba\u8981\u638c\u63e1\uff0c\u5b9e\u64cd\u4e0d\u80fd\u843d\uff01\u4ee5\u4e0a\u5173\u4e8e\u300a\u73b0\u4ee3\u4f4e\u4ee3\u7801\u6d4b\u8bd5\u5e73\u53f0\u300b\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u5927\u5bb6\u90fd\u638c\u63e1\u4e86\u5427\uff01\u5982\u679c\u60f3\u8981\u7ee7\u7eed\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\uff0c\u90a3\u4e48\u5c31\u6765\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u5427\uff01<\/p>\n<p>      \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb\u5220\u9664    <\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   TMI2024 | \u963f\u5927\u3001\u540c\u6d4e\u7b49\u63d0\u51faTraCoCo\uff0c\u7528\u4e8e3D\u533b\u5b66\u56fe\u50cf\u534a\u76d1\u7763\u5206\u5272\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u73b0\u4ee3\u4f4e\u4ee3\u7801\u6d4b\u8bd5\u5e73\u53f0 \u6536\u85cf \u6587\u7ae0\u5c0f\u767d\u4e00\u679a\uff0c\u6b63\u5728\u4e0d\u65ad\u5b66\u4e60\u79ef\u7d2f\u77e5\u8bc6\uff0c\u73b0\u5c06\u5b66\u4e60\u5230\u7684\u77e5\u8bc6\u8bb0\u5f55\u4e00\u4e0b\uff0c\u4e5f\u662f\u5c06\u6211\u7684\u6240\u5f97\u5206\u4eab\u7ed9\u5927\u5bb6\uff01\u800c\u4eca\u5929\u8fd9\u7bc7\u6587\u7ae0\u300a\u73b0\u4ee3\u4f4e\u4ee3\u7801\u6d4b\u8bd5\u5e73\u53f0\u300b\u5e26\u5927\u5bb6\u6765\u4e86\u89e3\u4e00\u4e0b##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01 \u901a\u8fc7\u667a\u80fd\u5143\u7d20\u8bc6\u522b\u8fdb\u884c\u53ef\u89c6\u5316\u8bb0\u5f55\u548c\u56de\u653e \u73b0\u4ee3\u5de5\u5177\u73b0\u5728\u4f7f\u7528\u4eba\u5de5\u667a\u80fd\u6bd4\u4f20\u7edf\u9009\u62e9\u5668\u66f4\u53ef\u9760\u5730\u8bc6\u522b\u5143\u7d20\u3002\u4f8b\u5982\uff1a \u87d2\u86c7 # traditional explicit selector approach button = driver.find_element(by.xpath, &#8220;\/\/button[@id=&#8217;submit-btn&#8217; or contains(@class, &#8216;submit&#8217;)]&#8221;) # modern low-code equivalent (automatically generates multiple fallback strategies) click(&#8220;submit&#8221;) # the tool automatically tries: # &#8211; text content matching # &#8211; partial class matching # &#8211; visual recognition # &#8211; nearby element context # &#8211; element [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-53377","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=53377"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53377\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}