<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Testing Technology on Testing Observation</title><link>https://chengxiaqiucao.github.io/en/tags/testing-technology/</link><description>Recent content in Testing Technology on Testing Observation</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>|by Daniel Wei</copyright><lastBuildDate>Sun, 12 Oct 2025 20:51:27 +0800</lastBuildDate><atom:link href="https://chengxiaqiucao.github.io/en/tags/testing-technology/index.xml" rel="self" type="application/rss+xml"/><item><title>What to Do When There Is Not Enough Testing Time?</title><link>https://chengxiaqiucao.github.io/en/post/130-when_qa_out_time/</link><pubDate>Sun, 12 Oct 2025 20:51:27 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/130-when_qa_out_time/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012.webp" alt="Featured image of post What to Do When There Is Not Enough Testing Time?" />&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012_hu_d3da7868660eed24.webp"
width="1024"
height="567"
srcset="https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012_hu_7a77c2852ccb1091.webp 480w, https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012_hu_d3da7868660eed24.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="180"
data-flex-basis="433px"
>
&lt;/p>
&lt;blockquote>
&lt;p>Product manager: &amp;ldquo;The client pressure is unbearable, it must go live tomorrow!&amp;rdquo;
Developer: &amp;ldquo;The code was just merged, no time for thorough self-testing&amp;hellip;.&amp;rdquo;
Tester: looking at the long list of test cases, can only sigh silently&amp;hellip;&lt;/p>&lt;/blockquote>
&lt;p>Does this scenario feel all too familiar at the sprint stage of every project?&lt;/p>
&lt;p>When the project schedule is in jeopardy, development is delayed, requirements change&amp;hellip;&lt;/p>
&lt;p>All the pressure eventually rolls like a snowball to the last link - &lt;strong>testing&lt;/strong>.&lt;/p>
&lt;p>So the test engineer becomes the final &amp;ldquo;scapegoat&amp;rdquo; and the &amp;ldquo;gatekeeper&amp;rdquo; deciding the project&amp;rsquo;s fate. And the phrase &amp;ldquo;not enough testing time&amp;rdquo; becomes the sword of Damocles hanging over everyone&amp;rsquo;s head.&lt;/p>
&lt;p>But: &lt;strong>when testing never has enough time, the problem is by no means only in testing, and the main cause is not even in the testing phase.&lt;/strong>&lt;/p>
&lt;p>Behind this hides a deeper but more common dilemma of team collaboration.&lt;/p>
&lt;h2 id="is-the-testing-phase-reasonable-just-because-it-exists">Is &amp;ldquo;the Testing Phase&amp;rdquo; Reasonable Just Because It Exists?
&lt;/h2>&lt;p>In many teams&amp;rsquo; workflows, testing is seen as an independent, linear &amp;ldquo;phase&amp;rdquo;.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">graph LR
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">A(Requirements) --&amp;gt;B(Design)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> B --&amp;gt; C(Development)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> C --&amp;gt;D[**Testing**]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> D --&amp;gt;E(Release)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The process seems natural, but in actual work it hides great risk.&lt;/p>
&lt;p>Once any of the preceding links (such as design or development) has a problem and takes longer than expected, the time left for testing will be ruthlessly compressed. Testing goes from a &lt;code>quality assurance&lt;/code> phase to a &lt;code>risk cleanup&lt;/code> phase.&lt;/p>
&lt;p>QA&amp;rsquo;s work becomes that of a &lt;strong>firefighter&lt;/strong>, as if forced into a room already full of smoke, trying to find possible sources of fire before the house burns down. Not only inefficient, but extremely dangerous.&lt;/p>
&lt;p>Worse, this model also breeds an &amp;ldquo;us vs. them&amp;rdquo; adversarial culture:&lt;/p>
&lt;ul>
&lt;li>Development thinks: &amp;ldquo;Why is it all this module after so long testing? Do you even know how to test?&amp;rdquo;&lt;/li>
&lt;li>Testing thinks: &amp;ldquo;What lousy code! So many bugs in one module?&amp;rdquo;&lt;/li>
&lt;/ul>
&lt;p>Everyone no longer seems to be teammates fighting side by side, but stands in opposition to each other.&lt;/p>
&lt;p>Obviously, this is not what we want to see!&lt;/p>
&lt;h2 id="how-to-break-the-deadlock">How to Break the Deadlock?
&lt;/h2>&lt;p>So how do we break this curse of &amp;ldquo;not enough time&amp;rdquo;?&lt;/p>
&lt;p>The answer is not the common sight of testers working overtime until dawn, but a fundamental shift in thinking: &lt;strong>from &amp;ldquo;quality assurance&amp;rdquo; to &amp;ldquo;quality built in&amp;rdquo;.&lt;/strong>&lt;/p>
&lt;p>Quality is not &amp;ldquo;&lt;strong>tested&lt;/strong>&amp;rdquo; out at the last stage, but &amp;ldquo;&lt;strong>built&lt;/strong>&amp;rdquo; throughout the whole process. Testing should not be the final phase of a project either, but a &amp;ldquo;quality coach&amp;rdquo; that runs through the whole thing.&lt;/p>
&lt;h3 id="1-shift-testing-left-get-involved-early-instead-of-waiting-for-the-wrap-up">**1. Shift Testing Left, Get Involved Early Instead of Waiting for the &amp;ldquo;Wrap-up&amp;rdquo;
&lt;/h3>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012-1_hu_9a8c0edfdd2fd9c0.webp"
width="1024"
height="573"
srcset="https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012-1_hu_ac9988727a486a6.webp 480w, https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012-1_hu_9a8c0edfdd2fd9c0.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="178"
data-flex-basis="428px"
>
&lt;/p>
&lt;p>Do not wait until the code is written to think about testing. Let testers get involved from the very beginning, in &lt;strong>requirements review&lt;/strong> and the &lt;strong>design phase&lt;/strong>.&lt;/p>
&lt;p>What are the benefits of early tester involvement?&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Raise testability questions&lt;/strong>: Is this requirement&amp;rsquo;s logic clear? What are the boundary conditions? Are there &amp;ldquo;black boxes&amp;rdquo; that are hard to test?&lt;/li>
&lt;li>&lt;strong>Perform risk analysis&lt;/strong>: Which features are core high-risk areas? Which can have their testing priority appropriately lowered?&lt;/li>
&lt;li>&lt;strong>Prevent defects&lt;/strong>: Many bugs are already determined at the design stage. QA&amp;rsquo;s early intervention can &amp;ldquo;prevent&amp;rdquo; them at the lowest cost, rather than &amp;ldquo;finding&amp;rdquo; them with effort after development is complete.&lt;/li>
&lt;/ul>
&lt;p>Turn testers from &amp;ldquo;problem finders&amp;rdquo; into &amp;ldquo;risk preventers&amp;rdquo; - this is how value is maximized.&lt;/p>
&lt;h3 id="2-embrace-automation-to-maximize-tester-value">&lt;strong>2. Embrace Automation to Maximize Tester Value&lt;/strong>
&lt;/h3>&lt;p>Manual testing is exploratory and creative, but also time-consuming and error-prone. For regression test cases that are executed repeatedly, test automation is where it shines most.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Unit testing&lt;/strong>: Developers write their own UTs to ensure the stability of code modules.&lt;/li>
&lt;li>&lt;strong>Integration testing&lt;/strong>: Can ensure collaboration between modules works.&lt;/li>
&lt;li>&lt;strong>End-to-end (E2E) automation&lt;/strong>: Simulates user operations and covers core business flows.&lt;/li>
&lt;/ul>
&lt;p>Integrate test automation into the &lt;strong>CI/CD&lt;/strong> pipeline so it runs automatically on every code commit. This frees testers from heavy regression testing to focus on more valuable &lt;strong>exploratory testing&lt;/strong> and &lt;strong>complex scenario testing&lt;/strong>.&lt;/p>
&lt;h3 id="3-use-good-steel-on-the-blade">&lt;strong>3. Use Good Steel on the Blade&lt;/strong>
&lt;/h3>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012-2_hu_51524e782655fd18.webp"
width="1024"
height="1019"
srcset="https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012-2_hu_d3dc45da81685d84.webp 480w, https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012-2_hu_51524e782655fd18.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="100"
data-flex-basis="241px"
>
&lt;/p>
&lt;p>The cruel reality is that we can never have enough time to test 100% of the features. So testing smartly matters more than testing hard.&lt;/p>
&lt;p>Together with product and development, define the risk level of each feature based on &lt;strong>business impact&lt;/strong>, &lt;strong>usage frequency&lt;/strong>, and &lt;strong>code complexity&lt;/strong>.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>High-risk features&lt;/strong> (such as payment and login): Invest the most time and effort, doing in-depth, comprehensive testing.&lt;/li>
&lt;li>&lt;strong>Medium-risk features&lt;/strong>: Execute core cases to ensure the main paths are fine.&lt;/li>
&lt;li>&lt;strong>Low-risk features&lt;/strong> (such as text changes and color adjustments): Verify quickly, or even only verify online.&lt;/li>
&lt;/ul>
&lt;p>Apply limited testing resources precisely where they matter most.&lt;/p>
&lt;h3 id="4-quality-is-not-free-it-is-expensive">&lt;strong>4. Quality Is Not Free, It Is Expensive&lt;/strong>
&lt;/h3>&lt;p>&amp;ldquo;This requirement is so simple, why does testing take so long?&amp;rdquo;&lt;/p>
&lt;p>Behind this sentence is an underestimation of the value of testing work.&lt;/p>
&lt;p>At the early stage of project planning, all testing-related work - &lt;strong>test analysis, test case design, test execution, automation script maintenance&lt;/strong>, and so on - must be treated as formal tasks and included in project scheduling and effort estimation.&lt;/p>
&lt;p>Only when quality is regarded as a &amp;ldquo;first-class citizen&amp;rdquo; as important as feature development will it not be easily sacrificed.&lt;/p>
&lt;h3 id="5-an">&lt;strong>5. An &amp;ldquo;All-Hands Quality&amp;rdquo; Culture&lt;/strong>
&lt;/h3>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012-3_hu_975410bb2c633bbd.webp"
width="1024"
height="1003"
srcset="https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012-3_hu_7360294d587df28c.webp 480w, https://chengxiaqiucao.github.io/post/130-when_qa_out_time/Pasted-20251012-3_hu_975410bb2c633bbd.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="102"
data-flex-basis="245px"
>
&lt;/p>
&lt;p>This is the most important and also the hardest point.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Development&lt;/strong> should be responsible for code quality, writing clear, maintainable code, and completing necessary unit tests.&lt;/li>
&lt;li>&lt;strong>Product&lt;/strong> should be responsible for requirements quality, providing clear, unambiguous requirements documents.&lt;/li>
&lt;li>&lt;strong>QA&lt;/strong> should be responsible for the overall quality process, providing professional test strategies and risk feedback.&lt;/li>
&lt;/ul>
&lt;p>Only when everyone in the team regards &amp;ldquo;quality&amp;rdquo; as their own KPI will there no longer be mutual blame and buck-passing.&lt;/p>
&lt;p>Everyone&amp;rsquo;s goal becomes aligned: &lt;strong>to jointly build a product that satisfies users.&lt;/strong>&lt;/p>
&lt;h2 id="closing-thoughts">&lt;strong>Closing Thoughts&lt;/strong>
&lt;/h2>&lt;p>&amp;ldquo;Not enough testing time&amp;rdquo; has never been an isolated technical problem; it is a &lt;strong>process problem, a culture problem, and even more a team collaboration problem.&lt;/strong>&lt;/p>
&lt;p>What we need is not more desperate testing, but a healthier, more efficient collaboration system.&lt;/p>
&lt;p>When quality is no longer the endpoint of a phase, but a belief that runs throughout;
When QA is no longer a gatekeeper fighting alone, but a quality coach empowering the team!&lt;/p>
&lt;p>Only then can the curse of &amp;ldquo;not enough time&amp;rdquo; truly be broken.&lt;/p></description></item><item><title>Shift-Left Testing Is More Than Testers Getting Involved Early</title><link>https://chengxiaqiucao.github.io/en/post/124-testing_shift_left/</link><pubDate>Wed, 27 Aug 2025 16:31:25 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/124-testing_shift_left/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/124-testing_shift_left/Pasted-20250827-1.webp" alt="Featured image of post Shift-Left Testing Is More Than Testers Getting Involved Early" />&lt;h2 id="preface">Preface
&lt;/h2>&lt;p>In the traditional waterfall software development process, testing usually sits late in the SDLC, and testers take on the duty of &amp;ldquo;quality gatekeeper&amp;rdquo;. As agile development, DevOps, and other delivery models have been adopted, rapid iteration and continuous delivery have become the norm, and accordingly the concept of &amp;ldquo;shift-left testing&amp;rdquo; is mentioned frequently; many agile teams treat &amp;ldquo;shift-left testing&amp;rdquo; as an important practice.&lt;/p>
&lt;p>Many teams encourage testers to get involved in projects as early as possible, involving testers in requirements, design, and development, including requirements reviews, design discussions, pairing during development, unit/integration testing, continuous integration pipelines, test automation, and so on.&lt;/p>
&lt;p>In this article we will not discuss these specific practices of shift-left testing, but rather clarify one point: &lt;strong>&amp;ldquo;shift-left testing&amp;rdquo; is not merely testers moving toward the front end&lt;/strong>&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/124-testing_shift_left/Pasted-20250827-1_hu_9f4345ad4f2a000f.webp"
width="1024"
height="552"
srcset="https://chengxiaqiucao.github.io/post/124-testing_shift_left/Pasted-20250827-1_hu_d271f541656de579.webp 480w, https://chengxiaqiucao.github.io/post/124-testing_shift_left/Pasted-20250827-1_hu_9f4345ad4f2a000f.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="185"
data-flex-basis="445px"
>
&lt;/p>
&lt;h2 id="software-quality">Software Quality
&lt;/h2>&lt;p>What is software quality? The definition in &lt;strong>IEEE.1061&lt;/strong> is as follows:&lt;/p>
&lt;blockquote>
&lt;p>Software quality is the degree to which a software product satisfies stated requirements as well as implicit needs arising from user needs and expectations.&lt;/p>&lt;/blockquote>
&lt;p>This definition is quite abstract, and it also shows indirectly that quality is a product attribute that is rather hard to define precisely.&lt;/p>
&lt;p>Roles with different perspectives actually see quality differently.&lt;/p>
&lt;h3 id="user-perspective">User Perspective
&lt;/h3>&lt;p>Quality is the degree to which user needs and expectations are met. That is, can the product help users solve specific problems? Is it convenient and fast? Stable and reliable? Good value for money?&lt;/p>
&lt;p>&amp;ldquo;This software is really easy to use!&amp;rdquo;
&amp;ldquo;This system is very stable and never crashes!&amp;rdquo;
&amp;ldquo;This app feels so smooth~&amp;rdquo;&lt;/p>
&lt;h3 id="developer-perspective">Developer Perspective
&lt;/h3>&lt;p>From a developer&amp;rsquo;s perspective, quality is reflected in the code and architecture.&lt;/p>
&lt;p>&amp;ldquo;Is the code standardized, readable, and maintainable?&amp;rdquo;
&amp;ldquo;Clear architecture, easy to extend&amp;rdquo;
&amp;ldquo;Technical debt is under control&amp;rdquo;&lt;/p>
&lt;h3 id="tester-perspective">Tester Perspective
&lt;/h3>&lt;p>From a tester&amp;rsquo;s perspective, beyond bringing in the user&amp;rsquo;s experience, quality is more about adaptability across multiple scenarios.&lt;/p>
&lt;p>The degree to which the software fits various scenarios such as happy path, angry path, scary path, greedy path, and so on.&lt;/p>
&lt;h3 id="management-perspective">Management Perspective
&lt;/h3>&lt;p>From a management perspective, quality is reflected in whether delivery is on time, whether the budget is under control, and whether product metrics are met.&lt;/p>
&lt;p>&amp;ldquo;The product is delivered on time with high quality&amp;rdquo;
&amp;ldquo;R&amp;amp;D costs are greatly reduced&amp;rdquo;
&amp;ldquo;The system runs stably with 99.999% availability&amp;rdquo;&lt;/p>
&lt;h3 id="business-perspective">Business Perspective
&lt;/h3>&lt;p>From a business operations perspective, quality measures the degree to which the product creates value and competitive advantage.&lt;/p>
&lt;p>&amp;ldquo;User downloads&amp;rdquo;, &amp;ldquo;user registrations&amp;rdquo;, &amp;ldquo;order conversion rate&amp;rdquo;, &amp;ldquo;user retention rate&amp;rdquo;, and so on&amp;hellip;.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/124-testing_shift_left/Pasted-20250827-2_hu_86f84c6df08d616f.webp"
width="1024"
height="561"
srcset="https://chengxiaqiucao.github.io/post/124-testing_shift_left/Pasted-20250827-2_hu_d76a41f015899b10.webp 480w, https://chengxiaqiucao.github.io/post/124-testing_shift_left/Pasted-20250827-2_hu_86f84c6df08d616f.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="182"
data-flex-basis="438px"
>
&lt;code>A thousand Hamlets in a thousand people's eyes&lt;/code> - so it is with quality too!&lt;/p>
&lt;p>In the end, it comes down to what we often stress: quality is not guaranteed by testing, and testing cannot guarantee it either! Quality is closely tied to the whole team and to everyone in the software lifecycle chain; everyone should be an owner!&lt;/p>
&lt;h2 id="the-essence-of-shift-left-testing">The Essence of Shift-Left Testing
&lt;/h2>&lt;p>With the explanation in the previous section, it becomes easy to understand the point of this article&amp;rsquo;s title: &lt;code>&amp;quot;shift-left testing&amp;quot; is not merely testers moving forward!&lt;/code>&lt;/p>
&lt;p>Because of the adoption of rapid iteration and continuous delivery, this quality control measure that emerged accordingly moves testers forward. Although testing-related activities are no longer confined to late-stage verification, if quality still depends on testers&amp;rsquo; activities, it is still treating the symptoms rather than the root cause.&lt;/p>
&lt;p>&lt;strong>Shift-left testing&lt;/strong> is essentially the popularization of an all-hands quality culture. Testers shifting left should, more importantly, bring the testing mindset - uniquely sensitive to quality risks - to the front end, and drive the whole team to build a quality-first cultural atmosphere.&lt;/p>
&lt;p>That is, &lt;strong>testing should transform toward [QA]!&lt;/strong> And the &lt;code>QA&lt;/code> here is not &lt;code>Quality Assurance&lt;/code> in the traditional sense, which focuses on process control and quality assurance work; it should be a new type of QA suited to the agile model.&lt;/p>
&lt;h2 id="testings-transformation-toward-qa">Testing&amp;rsquo;s Transformation Toward QA
&lt;/h2>&lt;h3 id="quality-assurance">Quality Assurance
&lt;/h3>&lt;p>The traditional QA role, &lt;code>Quality Assurance&lt;/code>, is a role dedicated to the quality system and is not the same as the testing role. QA&amp;rsquo;s work is more about formulating and supervising quality standards, with process control across the entire lifecycle; testing, on the other hand, is more of an engineering role based on testing technology.&lt;/p>
&lt;p>With the shift-left trend, testing should no longer be confined to the application of testing technology, but should turn its perspective to &lt;code>Quality Assurance&lt;/code>, paying attention to quality risks at every link in the entire software development chain.&lt;/p>
&lt;h3 id="quality-analyzer">Quality Analyzer
&lt;/h3>&lt;p>That is actually not enough! Shift-left testing is not a role switch; more importantly, it also involves introducing the testing mindset. So at this point, testing should also be a &lt;code>Quality Analyzer&lt;/code>. For example:&lt;/p>
&lt;h4 id="during-requirements-review">During requirements review:
&lt;/h4>&lt;p>&lt;strong>Find the gray areas&lt;/strong>: Proactively identify ambiguities in requirements. For example, &amp;ldquo;the system response should be fast&amp;rdquo; - how fast is fast? &amp;ldquo;A friendly user interface&amp;rdquo; - how is friendly defined?&lt;/p>
&lt;p>&lt;strong>Raise &amp;ldquo;What if&amp;rdquo; questions&lt;/strong>: Explore various scenarios, including normal flows, exception flows, and boundary cases:&lt;/p>
&lt;ul>
&lt;li>&amp;ldquo;What happens if the user enters special characters here?&amp;rdquo;&lt;/li>
&lt;li>&amp;ldquo;If the network suddenly drops, how will the data be handled?&amp;rdquo;&lt;/li>
&lt;li>&amp;ldquo;If the user has no permission, what prompt should be shown?&amp;rdquo;&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Ensure requirements are testable&lt;/strong>: Assess whether each requirement can be verified through concrete operations and expected results&lt;/p>
&lt;h4 id="during-the-architecturedesign-phase">During the architecture/design phase:
&lt;/h4>&lt;p>&lt;strong>Start from the user&amp;rsquo;s perspective&lt;/strong>: Check whether the design&amp;rsquo;s flows are smooth and intuitive&lt;/p>
&lt;p>&lt;strong>Focus on edge cases&lt;/strong>: Whether loading states, error prompts, empty-state pages, etc. have all been designed&lt;/p>
&lt;p>&lt;strong>Assess accessibility&lt;/strong>: Consider whether the design is friendly to all user groups&lt;/p>
&lt;p>&lt;strong>Assess system testability&lt;/strong>: Ensure the system is verifiable, including log recording, traceability of operation flows, third-party mocking, and so on&lt;/p>
&lt;p>&lt;strong>Assess non-functional requirements and test strategy&lt;/strong>: Ensure that the architecture and design phase has fully considered performance, security, reliability, and other non-functional requirements, and build corresponding test plans&lt;/p>
&lt;h4 id="during-development">During development:
&lt;/h4>&lt;p>&lt;strong>Drive unit test coverage&lt;/strong>: Help the development team build unit test frameworks and improve test coverage&lt;/p>
&lt;p>&lt;strong>Go deep into system integration&lt;/strong>: Work with the development team to build a continuous integration CI pipeline based on a suitable branch management model, and build the &lt;code>quality gate&lt;/code> for test automation&lt;/p>
&lt;p>By deeply participating in the front-end links, test thinking and reflection on and keen observation of software quality are integrated into software development activities beyond testing.&lt;/p>
&lt;h3 id="quality-advocator">Quality Advocator
&lt;/h3>&lt;p>In addition, a quality culture does not happen overnight. In a fast-moving team, a role that puts quality first, continuously advocates quality awareness to the team, and can promptly raise &amp;ldquo;objections&amp;rdquo; when quality is at risk of losing control is even more an important function of testers after &amp;ldquo;shift-left testing&amp;rdquo;.&lt;/p>
&lt;p>But for this new function to work, it cannot do without the team&amp;rsquo;s and management&amp;rsquo;s consistent recognition of &lt;strong>quality first&lt;/strong>, including institutional support for testers&amp;rsquo; related work after shifting left. Otherwise, quality first will mostly remain a formality, nothing more than a catchy slogan.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/124-testing_shift_left/Pasted-20250827_hu_fad4a6a43da71da3.webp"
width="1024"
height="471"
srcset="https://chengxiaqiucao.github.io/post/124-testing_shift_left/Pasted-20250827_hu_c51cb5cb08423bdd.webp 480w, https://chengxiaqiucao.github.io/post/124-testing_shift_left/Pasted-20250827_hu_fad4a6a43da71da3.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="217"
data-flex-basis="522px"
>
&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>With the continuous development of agile and DevOps technologies, the speed, rhythm, and complexity of software development keep increasing. In this context, for shift-left testing to be truly implemented, building a quality culture is actually fundamental.&lt;/p>
&lt;p>And in this process, testing also needs to complete its role transformation, moving toward quality consultant, quality analyst, and quality advocator, and delivering value on a broader scale.&lt;/p>
&lt;p>In short, implementing &amp;ldquo;shift-left testing&amp;rdquo; requires integrating quality thinking into every link of development, branding the quality culture into the team&amp;rsquo;s DNA, and ultimately building a quality ecosystem with full participation and continuous improvement.&lt;/p></description></item><item><title>Dare to Be a Dissenter - More on Testers' Perception of Their Role</title><link>https://chengxiaqiucao.github.io/en/post/123-testing_not_valid/</link><pubDate>Wed, 20 Aug 2025 16:01:41 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/123-testing_not_valid/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/123-testing_not_valid/Pasted-20250825-2.webp" alt="Featured image of post Dare to Be a Dissenter - More on Testers' Perception of Their Role" />&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/123-testing_not_valid/Pasted-20250825-2_hu_665c0e470108848e.webp"
width="1024"
height="683"
srcset="https://chengxiaqiucao.github.io/post/123-testing_not_valid/Pasted-20250825-2_hu_5068e2c36faf82e8.webp 480w, https://chengxiaqiucao.github.io/post/123-testing_not_valid/Pasted-20250825-2_hu_665c0e470108848e.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="149"
data-flex-basis="359px"
>
&lt;/p>
&lt;h2 id="preface">Preface
&lt;/h2>&lt;p>A few days ago, I read a &lt;a class="link" href="https://www.ministryoftesting.com/articles/overcoming-the-trap-of-intellectual-conformity-tips-for-software-testers?utm_campaign=Software%2BTesting%2BWeekly&amp;amp;utm_medium=web&amp;amp;utm_source=Software_Testing_Weekly_280" target="_blank" rel="noopener"
>blog post&lt;/a> by the foreign blogger &lt;code>Vitaly Sharovatov&lt;/code>, about the &amp;ldquo;trap of intellectual conformity&amp;rdquo; in enterprises and R&amp;amp;D teams. Because of the &lt;strong>trap of intellectual conformity&lt;/strong>, many avoidable wrong decisions get pushed through. And testers can play a more critical role in this.&lt;/p>
&lt;p>It was quite inspiring to read; after some deep thought, I wrote this article to share with you all~&lt;/p>
&lt;h2 id="the-trap-of-intellectual-conformity">The Trap of Intellectual Conformity
&lt;/h2>&lt;blockquote>
&lt;p>The &lt;strong>trap of intellectual conformity&lt;/strong> refers to the tendency of an individual who holds a certain position or perception to selectively accept information consistent with it while ignoring or overlooking inconsistent information, thereby forming a self-reinforcing cognitive loop that makes it difficult to assess reality objectively.&lt;/p>&lt;/blockquote>
&lt;p>In the 1950s, psychologists such as Festinger, Carlsmith, and Solomon Asch conducted many related experiments, confirming the widespread existence of cognitive conformity bias:&lt;/p>
&lt;ul>
&lt;li>When performing boring tasks, subjects paid less were more likely than those paid more to change their original evaluation, to rationalize the conflict between their behavior and the outcome.&lt;/li>
&lt;li>In another experiment, most subjects changed their originally correct choice because of other people&amp;rsquo;s wrong answers.&lt;/li>
&lt;li>When the same food was priced differently, subjects tended to believe the more expensive food tasted better.&lt;/li>
&lt;/ul>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/123-testing_not_valid/Pasted-20250825-1_hu_4a1882e6ab3fb1d6.webp"
width="1024"
height="684"
srcset="https://chengxiaqiucao.github.io/post/123-testing_not_valid/Pasted-20250825-1_hu_62e2d3a34d3bde29.webp 480w, https://chengxiaqiucao.github.io/post/123-testing_not_valid/Pasted-20250825-1_hu_4a1882e6ab3fb1d6.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="149"
data-flex-basis="359px"
>
&lt;/p>
&lt;p>In short, the experiments above are what we call the &amp;ldquo;&lt;strong>conformity mentality&lt;/strong>&amp;rdquo;&lt;/p>
&lt;h2 id="quality-risks-caused-by-intellectual-conformity">Quality Risks Caused by Intellectual Conformity
&lt;/h2>&lt;p>In enterprises, quality problems caused by the &amp;ldquo;conformity mentality&amp;rdquo; above and going along with the majority opinion are not uncommon.&lt;/p>
&lt;ul>
&lt;li>A development build that cannot even pass smoke testing is hastily submitted for testing, simply because the developers &amp;ldquo;feel&amp;rdquo; it is fine&lt;/li>
&lt;li>A feature that a leader thought up on a whim is rushed into development, and because it does not meet real user needs, it becomes a white elephant or even has to be rolled back&lt;/li>
&lt;li>Without investigation of the user base or analysis of real usage scenarios, a new feature is completely unusable&lt;/li>
&lt;/ul>
&lt;p>For the problems above, did really no one feel beforehand that something might be wrong? It is just that most people had no opinion, or the process reached a certain node, and it was pushed through by default.&lt;/p>
&lt;p>I once saw a view from a startup CEO: software testers are &amp;ldquo;more harmful than helpful&amp;rdquo; in terms of cost-effectiveness. If you hire only excellent developers with quality awareness, you do not need a dedicated quality role.&lt;/p>
&lt;p>But is that really the case? In my earlier articles, I discussed the difference between &amp;ldquo;developer thinking&amp;rdquo; and &amp;ldquo;tester thinking&amp;rdquo;:&lt;/p>
&lt;ul>
&lt;li>Developers tend to pursue &lt;strong>certainty&lt;/strong>. Based on definite requirements and steps, they define how the product should behave.&lt;/li>
&lt;li>Testers need to consider various possible paths and branch scenarios based on &lt;strong>uncertainty&lt;/strong>, and assess the product&amp;rsquo;s possible behavior based on the unknown.&lt;/li>
&lt;/ul>
&lt;p>Moreover, in a performance-driven organization, developers are hired to deliver results, not to question. They are evaluated on their ability to build, not on their ability to find and respond to problems.&lt;/p>
&lt;p>And based on the &lt;strong>trap of intellectual conformity&lt;/strong>, in an output-oriented organization, dissenting voices are continuously weakened, so even &lt;strong>developers with excellent quality awareness&lt;/strong> find it hard to put quality first in such an environment.&lt;/p>
&lt;h2 id="testing-the-dissenter-assigned-by-the-role">Testing, the &amp;ldquo;Dissenter&amp;rdquo; Assigned by the Role
&lt;/h2>&lt;p>Many people with a &amp;ldquo;conformity mentality&amp;rdquo; can actually sense that something is wrong; they just lack the courage to raise a &amp;ldquo;dissent&amp;rdquo;. But once a challenger appears who points out the problem, they too can actively offer opinions.&lt;/p>
&lt;p>And the testing role, by its very design, is assigned and expected to raise questions and challenges.&lt;/p>
&lt;p>This is precisely the necessity for the testing role to exist and matter: lowering the threshold for others to dissent and creating space for critical thinking in the team.&lt;/p>
&lt;p>As testers, we should not confine ourselves to the limits of the development lifecycle; we should actively shift testing left and participate more in earlier phases, so as to better demonstrate the value of the role.&lt;/p>
&lt;p>Of course, recognizing this also means accepting the positioning of being the &amp;ldquo;&lt;strong>bearer of bad news&lt;/strong>&amp;rdquo;. Face it calmly; a team&amp;rsquo;s path to success cannot do without such a role.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>Those who enjoy watching historical costume dramas should be familiar that in every dynasty there was an office such as the &amp;ldquo;censor&amp;rdquo; or &amp;ldquo;remonstrance official&amp;rdquo;. As advisers who spoke truth to power, they were mostly unwelcome to emperors and ministers, yet the operation of the system could not do without this function of supervision and review.&lt;/p>
&lt;p>And testers are very much like the &amp;ldquo;censors&amp;rdquo; in the system of software development.&lt;/p>
&lt;p>Do not fear the &amp;ldquo;&lt;strong>fail&lt;/strong>&amp;rdquo; on a test report; that is precisely the meaning of the testing function&amp;rsquo;s existence.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/123-testing_not_valid/Pasted-20250825_hu_9cdb16702f1207a9.webp"
width="1024"
height="767"
srcset="https://chengxiaqiucao.github.io/post/123-testing_not_valid/Pasted-20250825_hu_dd01b0253e8c5428.webp 480w, https://chengxiaqiucao.github.io/post/123-testing_not_valid/Pasted-20250825_hu_9cdb16702f1207a9.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="133"
data-flex-basis="320px"
>
&lt;/p></description></item><item><title>Fourteen Years Later, Revisiting "Testing Is Dead"</title><link>https://chengxiaqiucao.github.io/en/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/</link><pubDate>Wed, 30 Jul 2025 18:00:11 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/Pasted-20250730-1.webp" alt="Featured image of post Fourteen Years Later, Revisiting "Testing Is Dead"" />&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/Pasted-20250730-1_hu_51b40093af423870.webp"
width="1024"
height="577"
srcset="https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/Pasted-20250730-1_hu_e5de76ad1f21ad9d.webp 480w, https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/Pasted-20250730-1_hu_51b40093af423870.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="177"
data-flex-basis="425px"
>
&lt;/p>
&lt;h2 id="introduction">Introduction
&lt;/h2>&lt;p>Going back fourteen years, to October 2011, at Google&amp;rsquo;s &lt;code>GTAC&lt;/code> (Google Test Automation Conference), &lt;code>Alberto Savoia&lt;/code> walked onto the stage dressed as the Grim Reaper and dramatically declared that &amp;ldquo;software testing is dead&amp;rdquo;.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/Pasted-20250730_hu_5aa5456d0b596281.webp"
width="1024"
height="670"
srcset="https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/Pasted-20250730_hu_73de283ab7e4afb8.webp 480w, https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/Pasted-20250730_hu_5aa5456d0b596281.webp 1024w"
loading="lazy"
alt="savoia’s talk"
class="gallery-image"
data-flex-grow="152"
data-flex-basis="366px"
>
&lt;/p>
&lt;p>Soon after, the testing heavyweight &lt;code>Jame Whittaker&lt;/code> made the same declaration, &lt;code>Test is Dead&lt;/code>, at another testing conference, &lt;code>EuroSTAR&lt;/code>.&lt;/p>
&lt;p>The point of these remarks was the belief that software testing no longer needs to be an independent role in the software development process. With mature software processes and tools, macro-level quality problems no longer require a relatively large, dedicated team to guarantee them. Instead, testing should evolve into a series of micro-activities distributed among other roles, such as project managers, developers, and even end users.
Distribute testing activities across other phases of development.&lt;/p>
&lt;p>And as this manifesto spread widely, many tech giants, including Google and Microsoft, began to cut dedicated testing positions, and testing transformed into test development or software efficiency departments.&lt;/p>
&lt;p>But more than a decade later, has the testing profession really died out? On the contrary, &lt;strong>Whittaker&lt;/strong> himself published an article last year (2024) titled &amp;ldquo;The Resurrection of Software Testing&amp;rdquo;, re-examining the evolution of the testing industry (original text at &lt;a class="link" href="https://medium.com/@docjamesw/the-resurrection-of-software-testing-634423cd8411" target="_blank" rel="noopener"
>https://medium.com/@docjamesw/the-resurrection-of-software-testing-634423cd8411&lt;/a>)&lt;/p>
&lt;p>In this article, let&amp;rsquo;s delve into this topic again.&lt;/p>
&lt;h2 id="the-recurring-claim-that-testing-is-dead">The Recurring Claim That &amp;ldquo;Testing Is Dead&amp;rdquo;
&lt;/h2>&lt;p>From the time the &amp;ldquo;testing is dead&amp;rdquo; claim was made, it has in fact been raised many times. This saying has recurred in at least three periods:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>The Selenium open-source era&lt;/strong>: As automated testing tools gradually entered everyday enterprise use, machines replacing humans seemed within reach&lt;/li>
&lt;li>&lt;strong>The era of rampant automation frameworks and platforms&lt;/strong>: A large number of automated testing solutions flooded the market, all claiming they could greatly reduce testing work&lt;/li>
&lt;li>&lt;strong>Today&amp;rsquo;s AI era&lt;/strong>: With AI now in full swing, the old tune is replayed, claiming AI can already replace the work of testers&lt;/li>
&lt;/ol>
&lt;h3 id="why">Why?
&lt;/h3>&lt;p>Actually, on careful reflection, this cyclical recurrence is no accident; it reflects a common misalignment between technological change and industry perception. Whenever a new technology appears, people tend to be overly optimistic that it can completely replace human judgment and creativity.&lt;/p>
&lt;p>Beyond that, the testing industry&amp;rsquo;s own perception of testing largely supplies fuel for this claim.&lt;/p>
&lt;h4 id="many-training-institutions-and-many-testers-themselves-do-not-regard-testing-as-a-discipline">Many training institutions, and many testers themselves, do not regard testing as a discipline
&lt;/h4>&lt;ul>
&lt;li>Enter the field with zero background&lt;/li>
&lt;li>Even a novice can do testing&lt;/li>
&lt;li>Testing is nothing but &amp;ldquo;clicking around&amp;rdquo;&lt;/li>
&lt;li>Knowing how to write automation scripts makes you a senior tester&lt;/li>
&lt;/ul>
&lt;h4 id="companies-confuse-automation-with-testing">Companies confuse automation with testing
&lt;/h4>&lt;p>Many companies vigorously promote automation and set up test-development positions.&lt;/p>
&lt;p>But they fail to truly recognize that so-called automated testing is, more often than not, just &lt;code>checking&lt;/code>, which is far from real &lt;code>testing&lt;/code>.&lt;/p>
&lt;p>Test developers spend a great deal of time building frameworks and platforms, trying every means to improve efficiency with tools, but there are few real cases of achievements in expanding testing thinking or digging out deep quality problems.&lt;/p>
&lt;h4 id="unclear-testing-goals">Unclear testing goals
&lt;/h4>&lt;p>As said before, there are many who believe testing exists to verify requirements. Testers are more like &amp;ldquo;quality inspectors&amp;rdquo; holding a checklist, judging by whether specifications are met rather than whether the product can deliver value.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/kanban_hu_db7cce2d3788d84e.webp"
width="1024"
height="598"
srcset="https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/kanban_hu_822e9c734857b46d.webp 480w, https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/kanban_hu_db7cce2d3788d84e.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="171"
data-flex-basis="410px"
>
&lt;/p>
&lt;p>It is precisely these widespread misconceptions across the testing industry that do enormous harm to testing itself.&lt;/p>
&lt;p>But even after testing positions are cut? TDD, BDD, and starting with the end in mind mean developers actually take on testing duties; or end customers are made to act as testers without knowing it, and once they find a problem, people scramble to fix it quickly.&lt;/p>
&lt;p>So it is not that testing is dead; only the party responsible for performing testing and the division of responsibilities have shifted.&lt;/p>
&lt;h2 id="what-kind-of-testing-should-truly-die-out">What Kind of &amp;ldquo;Testing&amp;rdquo; Should Truly Die Out?
&lt;/h2>&lt;p>Just as I have stressed in several earlier articles about the real purpose of software testing. 【】&lt;/p>
&lt;p>The true purpose of testing is neither simply to verify requirements nor merely to find bugs.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/testing-checking_hu_dd929c89bdafaa47.webp"
width="1024"
height="782"
srcset="https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/testing-checking_hu_49031c7ebfaab54e.webp 480w, https://chengxiaqiucao.github.io/post/115-%E6%B5%8B%E8%AF%95%E5%B7%B2%E6%AD%BB10%E5%B9%B4/testing-checking_hu_dd929c89bdafaa47.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="130"
data-flex-basis="314px"
>
&lt;/p>
&lt;p>A clear distinction should also be drawn between &lt;code>testing&lt;/code> and &lt;code>checking&lt;/code>. As technology advances, the &lt;code>checking&lt;/code> part of testing is what should gradually be weakened and removed from testing responsibilities.&lt;/p>
&lt;p>Automated testing, those checklists of test cases and the green progress bars on CI dashboards, really cannot count as testing genuinely oriented toward quality; all they bring is a false sense of security.&lt;/p>
&lt;p>These &amp;ldquo;checkbox activities&amp;rdquo; that tick through items according to pre-written scripts are the part that should truly be distinguished from testing and should die out.&lt;/p>
&lt;p>Spending large amounts of time writing and maintaining these formalized test cases and test scripts actually reduces the real &lt;code>testing&lt;/code> time available for exploring the product and gaining insight into risks, and in fact harms the true value of testing.&lt;/p>
&lt;h3 id="automated-testing-vs-real-testing">Automated Testing vs. Real Testing
&lt;/h3>&lt;p>We must clarify the following core understanding:&lt;/p>
&lt;p>&lt;strong>Automated testing is usually only used to check what is already known, the behavior we expect the system to perform.&lt;/strong>
&lt;strong>Real testing, on the other hand, is about the unknown. It is a discipline that requires investigation, exploration, questioning, reasoning, experimentation, and verification. No script or AI can fully replace it.&lt;/strong>&lt;/p>
&lt;p>The true value of testing should always lie in exploring the unknown, in discovering problems that cannot be foreseen through automation.&lt;/p>
&lt;h2 id="redefining-the-value-of-testing">Redefining the Value of Testing
&lt;/h2>&lt;p>Testing is not only about finding bugs, nor only about tools. Its value should include:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Understanding product risks&lt;/strong>: Identifying potential problems that could affect users or the business&lt;/li>
&lt;li>&lt;strong>Communicating uncertainty&lt;/strong>: Clearly conveying findings about product quality and risk&lt;/li>
&lt;li>&lt;strong>Modeling user behavior&lt;/strong>: Predicting how real users will interact with the system&lt;/li>
&lt;li>&lt;strong>Finding problems others missed&lt;/strong>: Offering a unique perspective and insight&lt;/li>
&lt;/ul>
&lt;p>These values are indispensable in any software development lifecycle. When an organization truly understands these values, testing will inevitably take an important role in the software development process, whether performed by dedicated testers or by developers and other roles.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;blockquote>
&lt;p>&lt;strong>Testing has never died; it only keeps being reborn!&lt;/strong>&lt;/p>&lt;/blockquote>
&lt;p>The &amp;ldquo;testing is dead&amp;rdquo; claim surfaces every few years, but testing has never truly died.
It only keeps evolving - from manual testing to automation, from an independent role to distributed responsibility, from verifying the known to exploring the unknown. Every evolution is the result of testing adapting to new environments and new technologies.&lt;/p>
&lt;p>Today, as we face the wave of AI, the same story is replaying. Some predict AI will replace testers, but history tells us that technology changes the way testing is done, not the need for it. AI can automate more tasks, but the critical thinking, creativity, and systems thinking of human testers remain irreplaceable.&lt;/p>
&lt;p>The future of testing does not lie in resisting change, but in embracing evolution. Testers need to develop new skills and adopt new tools, but more importantly, they must hold fast to the core value of testing - exploring the unknown, assessing risk, and safeguarding quality.&lt;/p></description></item><item><title>When AI Writes Applications, a Blessing or a Challenge for Quality?</title><link>https://chengxiaqiucao.github.io/en/post/113-test_ai_coded_app/</link><pubDate>Thu, 24 Jul 2025 16:49:36 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/113-test_ai_coded_app/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/113-test_ai_coded_app/ai_check.webp" alt="Featured image of post When AI Writes Applications, a Blessing or a Challenge for Quality?" />&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/113-test_ai_coded_app/ai_check_hu_e9cc545f9a7ff80a.webp"
width="1024"
height="587"
srcset="https://chengxiaqiucao.github.io/post/113-test_ai_coded_app/ai_check_hu_80d2c40fc4f90117.webp 480w, https://chengxiaqiucao.github.io/post/113-test_ai_coded_app/ai_check_hu_e9cc545f9a7ff80a.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="174"
data-flex-basis="418px"
>
&lt;/p>
&lt;h1 id="when-ai-writes-applications-a-blessing-or-a-challenge-for-quality">When AI Writes Applications, a Blessing or a Challenge for Quality?
&lt;/h1>&lt;p>As AI models become increasingly capable, AI programming tools represented by Copilot, Cursor, Claude Code, and Gemini Cli are gradually entering everyday software development, and &amp;ldquo;vibe coding&amp;rdquo; is increasingly becoming a trend in application development.&lt;/p>
&lt;p>So when AI becomes more and more involved in the development of real applications, is the quality of applications built in this way good or bad?&lt;/p>
&lt;p>This article shares my views based on my recent experience using several vibe coding tools.&lt;/p>
&lt;h2 id="ai-programming-looks-beautiful">AI Programming Looks Beautiful
&lt;/h2>&lt;p>From the moment people first encounter AI programming, many are amazed by its extremely fast and efficient power. Combined with good prompt engineering, it can often complete prototype design in a very short time, and the resulting product is frequently more feature-complete than expected.&lt;/p>
&lt;p>As long as we have some understanding of software application development, combined with prompt engineering, AI can help us with everything from design to code, from the front end and back end to the database. What engineers need to do seems to be continuously communicating with the AI and constantly optimizing and adjusting the output.&lt;/p>
&lt;p>It can be said that the emergence of AI programming tools has enabled many non-programmers to develop a wide range of creative applications, greatly lowering the barrier to software development.&lt;/p>
&lt;p>In major software development companies, it is gradually becoming the norm for developers to write more and more code with the help of AI tools.&lt;/p>
&lt;p>The future of AI programming is so close, and so beautiful~&lt;/p>
&lt;p>However, if the goal is not merely to validate a prototype, and we judge an AI-developed application by the standards of a production-grade application, then a complex and painful debugging process will inevitably be part of the picture.&lt;/p>
&lt;p>&amp;ldquo;Ten minutes of development, two whole days of debugging&amp;rdquo; is actually the norm when it comes to AI programming.&lt;/p>
&lt;h2 id="when-the-ais-imagination-leaves-you-speechless">When the AI&amp;rsquo;s Imagination Leaves You Speechless
&lt;/h2>&lt;p>Although &amp;ldquo;prompt engineering&amp;rdquo; summarizes and emphasizes some of the best ways to collaborate with AI, in real work, engineers often still tend to communicate with the AI using brief instructions.&lt;/p>
&lt;p>When such instructions are insufficient and imprecise, the AI will naturally imagine a great deal of code that it considers necessary but that is actually plausible yet wrong. At this point, engineers inevitably need to spend a large amount of time checking and adjusting the AI&amp;rsquo;s behavior.&lt;/p>
&lt;p>Anyone who has coded with AI has likely had the experience of spending a huge amount of time on some basic logic or front-end interface adjustment.&lt;/p>
&lt;p>For example, I once encountered a case where I simply wanted to add a field to a page form and adjust the back-end database accordingly. Yet the AI always misread the intent — either it didn&amp;rsquo;t sync the change, or it modified other unrelated forms. The back-and-forth dragged on and consumed a lot of time.&lt;/p>
&lt;p>What should have been a two-line change turned into a situation where, because I wasn&amp;rsquo;t familiar with the structure of the AI-generated code, I relied on the AI to revise it over and over. Although the desired result was finally achieved, a large amount of needless spaghetti code was inserted along the way.&lt;/p>
&lt;h2 id="weaknesses-in-integration-and-decoupling">Weaknesses in Integration and Decoupling
&lt;/h2>&lt;p>When AI generates code, it generally first determines the project&amp;rsquo;s code structure based on the initial requirements, and then fills in the code according to specific decomposed tasks.&lt;/p>
&lt;p>But as the project progresses and requirements are continuously refined, the main logic usually ends up concentrated in a few main files, which easily makes some of those files overly bloated. And because AI relies on large models, which usually have context window limitations, bloated files greatly constrain the efficiency and quality of code generation.&lt;/p>
&lt;p>Therefore, as requirements are continuously detailed and adjusted, the code becomes increasingly bloated and increasingly chaotic. It rarely undergoes proper decoupling and refactoring as it would in real engineering practice, and the AI&amp;rsquo;s own understanding of the code often becomes more and more difficult, making it hard to recapture that initial sense of amazement.&lt;/p>
&lt;p>At this point, engineer intervention is essential; otherwise, AI coding becomes more like trying to carve flowers on a dunghill.&lt;/p>
&lt;h2 id="what-you-see-is-not-necessarily-what-you-get">What You See Is Not Necessarily What You Get
&lt;/h2>&lt;p>In order to present results quickly, AI-generated code sometimes &amp;ldquo;cheats&amp;rdquo; by hard-coding the presentation of certain data effects.&lt;/p>
&lt;p>In the early stage, some mock data may be indispensable to demonstrate results. But you cannot fully trust the AI to distinguish hard-coding from properly handled logic.&lt;/p>
&lt;p>In an AI-assisted tool I once used, I pointed out to it that after I entered a certain specific piece of data, the actual result didn&amp;rsquo;t match expectations. After pretending to analyze things for a long time, the AI told me it had found the cause. But when I actually checked the code, I discovered that its handling of this part was simply an if check targeting that specific piece of data, forcing a special case and calling it a day.&lt;/p>
&lt;h2 id="challenges-to-quality">Challenges to Quality
&lt;/h2>&lt;p>So, from the explanations (and complaints) above, although AI has achieved astonishing results in assisting coding, and there is no lack of cases where it cooperates well with engineers, many applications generated with AI assistance still cannot dispel concerns about questionable quality.&lt;/p>
&lt;p>Perhaps AI itself can help you generate unit tests, but just as intelligent driving still cannot replace human decision-making, in the field of quality, the role of human test engineers remains irreplaceable. Indeed, as AI applications become more widespread, the importance of manual testing becomes ever more prominent.&lt;/p>
&lt;ul>
&lt;li>The quality of the code itself&lt;/li>
&lt;li>Overall planning of complex applications and broad-context understanding&lt;/li>
&lt;li>Deficiencies in scalability, performance, security, and other aspects&lt;/li>
&lt;li>Mock data and hard-coding&lt;/li>
&lt;/ul>
&lt;h2 id="how-test-engineers-should-respond">How Test Engineers Should Respond
&lt;/h2>&lt;p>Given the quality challenges of AI-generated applications, test engineers should also carry out targeted testing and verification of their output.&lt;/p>
&lt;p>The following aspects can be considered as priorities:&lt;/p>
&lt;h4 id="systematic-verification-against-traditional-standards">Systematic Verification Against Traditional Standards
&lt;/h4>&lt;p>As a product, testing should first and foremost verify the finished AI application from the perspectives of requirements, product goals, and user usage, ensuring that it meets product requirements and quality standards.&lt;/p>
&lt;h4 id="product-integration-scalability-performance-and-security">Product Integration, Scalability, Performance, and Security
&lt;/h4>&lt;p>In view of the weak points of AI code, focus on scenarios such as product integration, scalability, performance, and security, and carry out targeted testing.&lt;/p>
&lt;h4 id="from-black-box-to-white-box">From Black Box to White Box
&lt;/h4>&lt;p>The existence of AI illusions requires test engineers not only to verify the application from a black-box perspective, but also to pay attention to the process by which the AI generated the application. In particular, during the development process, the relevant prompts, context, and records of the AI&amp;rsquo;s responses are all sources for understanding potential quality problems. Many issues, such as hard-coding, may be hidden in some misleading interactions.&lt;/p>
&lt;h4 id="embrace-ai-and-fight-magic-with-magic">Embrace AI and Fight Magic with Magic
&lt;/h4>&lt;p>Although AI still has many problems, and using it incorrectly can produce products of poor quality, using it properly can indeed provide great help.&lt;/p>
&lt;p>With AI, we can analyze product code and sort out the project architecture, helping us better understand the implementation of the project. This includes using AI to assist with many testing tasks, including automated testing.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>All in all, a good-quality product cannot do without a mature team and standardized processes. For testers, the AI era is also an opportunity to redefine our role. Embracing the challenges of AI-driven development, testers will also be indispensable participants and collaborators. Embrace AI, and embrace the future!&lt;/p></description></item><item><title>Is Testing Really Inferior to Development?</title><link>https://chengxiaqiucao.github.io/en/post/110-%E6%B5%8B%E8%AF%95%E5%92%8C%E5%BC%80%E5%8F%91%E7%9A%84%E6%AF%94%E8%BE%83/</link><pubDate>Sun, 13 Jul 2025 11:26:50 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/110-%E6%B5%8B%E8%AF%95%E5%92%8C%E5%BC%80%E5%8F%91%E7%9A%84%E6%AF%94%E8%BE%83/</guid><description>&lt;blockquote>
&lt;p>Someone asked whether people who do testing are really inferior to developers?&lt;/p>&lt;/blockquote>
&lt;p>Although everyone has their own view, it is still worth thinking about the mainstream view represented behind this question.&lt;/p>
&lt;p>Below I share Qiucao&amp;rsquo;s perspective.&lt;/p>
&lt;h2 id="testing-technology-and-development-technology-are-not-the-same-track">Testing Technology and Development Technology Are Not the Same Track
&lt;/h2>&lt;p>First of all, to truly do the testing job well, the skill requirements are actually quite high. But testing technology and development technology are technologies of different dimensions. A developer complaining about testers by comparing software development skills is like a basketball player mocking a swimmer for being slow at running.&lt;/p>
&lt;p>Testing technology includes many requirements that differ from development technology; for details, see my other earlier article 【】, which I will not repeat here.&lt;/p>
&lt;h2 id="real-reasons-why-testing-is-underrated">Real Reasons Why Testing Is Underrated
&lt;/h2>&lt;p>But we must also recognize this objective fact — in most enterprises, the say, salary, and so on of the testing position are usually a notch lower than those of developers at the same level.&lt;/p>
&lt;p>There are in fact multiple reasons for this situation, mainly the general perception of the role and a rather harsh industry environment. Specifically:&lt;/p>
&lt;h3 id="the-mismatch-between-job-requirements-and-expected-output">The Mismatch Between Job Requirements and Expected Output
&lt;/h3>&lt;p>First of all, most current testing job requirements actually revolve around verifying requirements — including test case design and test automation implementation, all of which are based on the verification of existing requirements.&lt;/p>
&lt;p>But verifying requirements is actually more &lt;strong>checking&lt;/strong> work than &lt;strong>testing&lt;/strong> work.&lt;/p>
&lt;p>Checking, as a subset of testing, actually has lower requirements and does not demand much technical skill. Correspondingly, job requirements centered on requirement verification are in fact requirements for a low-skill position.&lt;/p>
&lt;p>The contradiction, however, is that the expectation of the testing position is to guarantee comprehensive quality after the product is released. And the coverage requirements for product quality simply cannot be achieved through requirement verification alone.&lt;/p>
&lt;p>Requirement verification is mainly about functional coverage, and usually includes only basic scenarios, lacking all kinds of abnormal scenarios and non-functional scenarios. To achieve quality coverage, it is necessary to rely on full-process quality control during the development phase, including the &lt;strong>testing&lt;/strong> work in the testing phase. Here, &lt;strong>testing&lt;/strong> is not merely basic &lt;strong>checking&lt;/strong> — it must also include proactive discovery supported by a wider range of testing techniques.
&lt;img src="https://chengxiaqiucao.github.io/post/110-%E6%B5%8B%E8%AF%95%E5%92%8C%E5%BC%80%E5%8F%91%E7%9A%84%E6%AF%94%E8%BE%83/testing-checking_hu_dd929c89bdafaa47.webp"
width="1024"
height="782"
srcset="https://chengxiaqiucao.github.io/post/110-%E6%B5%8B%E8%AF%95%E5%92%8C%E5%BC%80%E5%8F%91%E7%9A%84%E6%AF%94%E8%BE%83/testing-checking_hu_49031c7ebfaab54e.webp 480w, https://chengxiaqiucao.github.io/post/110-%E6%B5%8B%E8%AF%95%E5%92%8C%E5%BC%80%E5%8F%91%E7%9A%84%E6%AF%94%E8%BE%83/testing-checking_hu_dd929c89bdafaa47.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="130"
data-flex-basis="314px"
>
&lt;/p>
&lt;p>And this mismatch between job requirements and expected output also leads to doubts about the effectiveness of the testing position.&lt;/p>
&lt;h3 id="lower-job-requirements-lead-to-a-lower-industry-barrier">Lower Job Requirements Lead to a Lower Industry Barrier
&lt;/h3>&lt;p>When the job requirements themselves mainly target low-skill &lt;strong>checking&lt;/strong> work, the entry barrier to the industry is naturally lowered too, and many newcomers with little experience or skill can enter the industry to perform the relevant checking work.&lt;/p>
&lt;p>In earlier years there was even a distinction between test design engineers and test execution engineers; here, test execution merely required following the cases to carry out operations and record the results. Such the most basic checking work can hardly be said to require much testing technology.&lt;/p>
&lt;p>A relatively low level of skill and job requirements naturally affects the overall evaluation of the position.&lt;/p>
&lt;h3 id="the-industrys-own-misdirection">The Industry&amp;rsquo;s Own Misdirection
&lt;/h3>&lt;p>The rapid development of the IT industry in earlier years and its relatively good compensation made IT a popular career choice. And for the reasons mentioned above, when low-skill checking work is dressed up in the clothes of testing work, such testing positions become the best entry channel for non-IT people to get into the industry.&lt;/p>
&lt;p>A large number of non-IT professionals hoping to enter the industry in turn generated a great deal of demand for training.&lt;/p>
&lt;p>Then, fueled by all kinds of training institutions — including hype about entering the industry with zero background and newcomers earning high salaries — large numbers of people were indeed delivered into the industry. The performance at work of these short-term, fast-track &amp;ldquo;talents&amp;rdquo; naturally affected the overall evaluation of the industry.&lt;/p>
&lt;h3 id="the-hardest-hit-area-in-the-industry-winter">The Hardest-Hit Area in the Industry Winter
&lt;/h3>&lt;p>As the IT winter arrived, enterprises, under cost pressure, cut spending and reduced headcount. Combined with all the factors mentioned above, this made testing the hardest-hit area — a vicious cycle in which the common perception of the testing position drifted even further from the value it deserves.&lt;/p>
&lt;h2 id="in-closing">In Closing
&lt;/h2>&lt;p>Objectively speaking, it is true that a large number of practitioners in the so-called &amp;ldquo;testing industry&amp;rdquo; in China today can hardly be called qualified, so saying it is inferior to development positions is not entirely wrong.&lt;/p>
&lt;p>But the &amp;ldquo;testing&amp;rdquo; here is in quotation marks — checking and testing are being confused as one.&lt;/p>
&lt;p>All in all, the overall environment of the entire testing industry today is rather harsh and misunderstandings run deep, and Qiucao feels quite powerless about it.&lt;/p>
&lt;p>There is no need to lose heart, however. If you build your own capability around the true goals of the role and deliver genuine value for comprehensive quality, you will naturally be the one still standing when the tide recedes.&lt;/p></description></item><item><title>Testability Is More Than Just Code</title><link>https://chengxiaqiucao.github.io/en/post/104-testablity/</link><pubDate>Sun, 29 Jun 2025 21:13:11 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/104-testablity/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/104-testablity/Pasted-20250916.webp" alt="Featured image of post Testability Is More Than Just Code" />&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/104-testablity/Pasted-20250916_hu_5a64574f0bc13277.webp"
width="1024"
height="1024"
srcset="https://chengxiaqiucao.github.io/post/104-testablity/Pasted-20250916_hu_807a3da5ae1b80a9.webp 480w, https://chengxiaqiucao.github.io/post/104-testablity/Pasted-20250916_hu_5a64574f0bc13277.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="100"
data-flex-basis="240px"
>
&lt;/p>
&lt;p>In the field of software development, we often define testability (Testability) as a technical metric: &lt;code>whether the code is easy to test&lt;/code>.&lt;/p>
&lt;p>In this article, let&amp;rsquo;s discuss it from a different perspective: testability is not only about code, but also about human nature.&lt;/p>
&lt;h2 id="testability-from-a-traditional-perspective">Testability from a Traditional Perspective
&lt;/h2>&lt;p>In most technical discussions, testability is confined to a narrow scope. We talk about &lt;code>modularity&lt;/code>, &lt;code>dependency injection&lt;/code>, &lt;code>logging&lt;/code>, and &lt;code>interface design&lt;/code> — all of these are meant to make the code easier to be covered by automated scripts or unit tests.&lt;/p>
&lt;p>Such a focus is understandable, because a well-designed system can indeed lower testing costs.&lt;/p>
&lt;p>However, stopping here means seeing only the tip of the iceberg.&lt;/p>
&lt;p>The success of a software product ultimately depends on whether it can run stably in the real world, and that real world is full of complex human factors and environmental challenges.&lt;/p>
&lt;p>If our testability only focuses on &lt;code>whether the code is easy to test&lt;/code>, then we ignore the most critical question:&lt;/p>
&lt;p>&lt;strong>For a specific person, in a specific situation, to test a specific product — exactly how easy is it?&lt;/strong>&lt;/p>
&lt;h2 id="true-testability">True Testability
&lt;/h2>&lt;p>Test engineers should be familiar with the following scenarios:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Automation test engineers spend most of a day not writing scripts, but dealing with &lt;strong>unstable test environments&lt;/strong>. Network fluctuations, service outages, and data pollution — factors unrelated to the code itself — can bring testing to a complete standstill. By the time the environment is finally ready, a whole day&amp;rsquo;s energy has often been exhausted.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Test teams need to go through &lt;strong>complex configuration and dependency&lt;/strong> installation steps before they can start certain tests, which makes manual testing and exploratory testing extremely inefficient. Under time pressure, team members may have to give up some tests, or can only perform the most superficial functional verification.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>There is a &lt;strong>lack of smooth communication&lt;/strong> between developers and testers. When a feature is hard to test because of high code coupling, testers often find themselves in a difficult position, while developers have a hard time realizing the difficulty this creates during testing and fail to provide timely assistance.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>All of the problems above, without exception, point to one fact:&lt;/p>
&lt;p>&lt;strong>True testability often does not lie in the complexity of the code, but in the entire ecosystem built around the product, and the people within it.&lt;/strong>&lt;/p>
&lt;p>A product that is hard to test brings more than just release delays. It also drains the team&amp;rsquo;s energy and stifles testers&amp;rsquo; curiosity and desire to explore.&lt;/p>
&lt;p>Moreover, it can even create a false sense of security that &amp;ldquo;the product is stable.&amp;rdquo; When defects that should have been found are missed because testing is too difficult, it is the quality after release and the end users that are ultimately affected.&lt;/p>
&lt;h2 id="how-to-improve-testability">How to Improve Testability
&lt;/h2>&lt;p>Once we understand the human dimension of testability, how should we solve this problem?&lt;/p>
&lt;p>Actually, the focus is a shift from &amp;ldquo;making code easier to test&amp;rdquo; to &amp;ldquo;making testers more able to test.&amp;rdquo;&lt;/p>
&lt;h3 id="1-redefining">&lt;strong>1. Redefining &amp;ldquo;Easy to Test&amp;rdquo;&lt;/strong>
&lt;/h3>&lt;p>When defining product features, consider more comprehensively:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Tool support&lt;/strong>: Do testers have handy tools?&lt;/li>
&lt;li>&lt;strong>Team culture&lt;/strong>: Does the team encourage sharing testing pain points and solving them together?&lt;/li>
&lt;li>&lt;strong>Business knowledge&lt;/strong>: Do testers fully understand the business requirements?&lt;/li>
&lt;li>&lt;strong>Work environment&lt;/strong>: Is the test environment stable and reliable?&lt;/li>
&lt;/ul>
&lt;h3 id="2-minimizing-obstacles">&lt;strong>2. Minimizing Obstacles&lt;/strong>
&lt;/h3>&lt;p>In a fast-paced iteration cycle, we always think &amp;ldquo;speed&amp;rdquo; is the top priority. But it should be noted that &lt;strong>the real bottleneck is not speed, but all kinds of obstacles&lt;/strong>. Reducing the friction in the testing process is more valuable than simply increasing test execution speed. This includes:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Simplifying environment setup&lt;/strong>: Use containerization technologies (such as Docker) or automation scripts to make test environment deployment a one-click process.&lt;/li>
&lt;li>&lt;strong>Clear documentation&lt;/strong>: Provide clear architecture diagrams, API documentation, and testing guides for complex systems, so newcomers can get started quickly.&lt;/li>
&lt;li>&lt;strong>Toolchain integration&lt;/strong>: Ensure that testing tools, CI/CD pipelines, and reporting systems work together seamlessly.&lt;/li>
&lt;/ul>
&lt;h3 id="3-tracking-the-degree-of-testability-with-reasonable-metrics">&lt;strong>3. Tracking the Degree of Testability with Reasonable Metrics&lt;/strong>
&lt;/h3>&lt;p>We can reflect the degree of testability in testing by collecting and tracking some testing process data.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Environment readiness time&lt;/strong>: On average, how long does it take to prepare a usable test environment?&lt;/li>
&lt;li>&lt;strong>Defect reproduction cost&lt;/strong>: How many steps and how much time does it take to reproduce a defect found in a production environment?&lt;/li>
&lt;li>&lt;strong>Feature testing time&lt;/strong>: How long does it take for a feature to go from development completion to passing testing?&lt;/li>
&lt;/ul>
&lt;p>These metrics help us measure testability more directly and help us make targeted improvements.&lt;/p>
&lt;h2 id="conclusion">&lt;strong>Conclusion&lt;/strong>
&lt;/h2>&lt;p>&lt;strong>Testability&lt;/strong> is, in essence, a topic about empathy and humanism.&lt;/p>
&lt;p>We should shift from the perspective of product attributes, to the perspective of supporting testers, and then expand to the perspective of collaboration across the entire team.&lt;/p>
&lt;p>Technology serves people, and the ultimate guarantee of software quality comes from respect for and support of people.
&lt;img src="https://chengxiaqiucao.github.io/post/104-testablity/Pasted-20250916-1_hu_12b77efec58fe3bd.webp"
width="1024"
height="574"
srcset="https://chengxiaqiucao.github.io/post/104-testablity/Pasted-20250916-1_hu_e43277f1130c9bc1.webp 480w, https://chengxiaqiucao.github.io/post/104-testablity/Pasted-20250916-1_hu_12b77efec58fe3bd.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="178"
data-flex-basis="427px"
>
&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/104-testablity/Pasted-20250916-2_hu_19a4dc350d7689ae.webp"
width="1024"
height="574"
srcset="https://chengxiaqiucao.github.io/post/104-testablity/Pasted-20250916-2_hu_1c1e68c46c7521a6.webp 480w, https://chengxiaqiucao.github.io/post/104-testablity/Pasted-20250916-2_hu_19a4dc350d7689ae.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="178"
data-flex-basis="427px"
>
&lt;/p></description></item><item><title>Open-Sourcing a Test Practice Project, Inviting Everyone to Build It Together</title><link>https://chengxiaqiucao.github.io/en/post/100-testmybookshelf/</link><pubDate>Thu, 19 Jun 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/100-testmybookshelf/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/100-testmybookshelf/snap_20250611.webp" alt="Featured image of post Open-Sourcing a Test Practice Project, Inviting Everyone to Build It Together" />&lt;p>I once collected some projects for testing practice; see the list in （）, but most of these projects are still aimed at automation testing practice, and there are very few projects truly used to practice software testing and defect-discovery skills, so the idea of making such a project myself was born.&lt;/p>
&lt;h3 id="design-approach">Design Approach
&lt;/h3>&lt;p>Taking the development of a project with real requirements as an example, it follows a simulated agile development process and iterates by Sprint. Each iteration is implemented according to the specified requirements, but at the same time contains some injected, known Bugs.&lt;/p>
&lt;p>Practitioners can treat the branch corresponding to each iteration (such as sprint0, sprint1) as a version submitted for testing, and conduct testing and practice on it. At the same time, they can also&lt;/p>
&lt;h3 id="invitation-to-build-together">Invitation to Build Together
&lt;/h3>&lt;p>Individual strength is limited, so I now invite all fellow testers to jointly improve this Demo project, including completing test cases, supplementing the list of existing Bugs and other related documents, so as to strive to provide testing beginners with a Demo that closely reflects real software development and has real learning value.&lt;/p>
&lt;p>Reply with &lt;code>join the group&lt;/code> to enter the testing discussion group, exchange testing techniques with fellow testers, and improve and progress together~&lt;/p>
&lt;h2 id="project-address-and-introduction">Project Address and Introduction
&lt;/h2>&lt;p>&lt;a class="link" href="https://github.com/chengxiaqiucao/TestMyBookshelf" target="_blank" rel="noopener"
>https://github.com/chengxiaqiucao/TestMyBookshelf&lt;/a>&lt;/p>
&lt;p>sprint homepage
&lt;img src="https://chengxiaqiucao.github.io/post/100-testmybookshelf/snap_20250611-1_hu_c032e60e3d404f39.webp"
width="1024"
height="307"
srcset="https://chengxiaqiucao.github.io/post/100-testmybookshelf/snap_20250611-1_hu_b97f509883dbbbc7.webp 480w, https://chengxiaqiucao.github.io/post/100-testmybookshelf/snap_20250611-1_hu_c032e60e3d404f39.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="333"
data-flex-basis="801px"
>
&lt;/p>
&lt;p>sprint1 homepage
&lt;img src="https://chengxiaqiucao.github.io/post/100-testmybookshelf/snap_20250611_hu_67f3f6e7bed6dd4.webp"
width="1024"
height="665"
srcset="https://chengxiaqiucao.github.io/post/100-testmybookshelf/snap_20250611_hu_d0c20d706014f9b0.webp 480w, https://chengxiaqiucao.github.io/post/100-testmybookshelf/snap_20250611_hu_67f3f6e7bed6dd4.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="154"
data-flex-basis="369px"
>
&lt;/p>
&lt;p>Feel free to open more Issues~~&lt;/p>
&lt;p>The ReadMe document is as follows:&lt;/p>
&lt;hr>
&lt;h1 id="personal-book-management--my-bookshelf">Personal Book Management &amp;ndash; My Bookshelf
&lt;/h1>&lt;p>A testing practice project | A library management system with injected defects | Implemented with FastAPI + SQLite | Suitable for QA training&lt;/p>
&lt;p>This is a personal book management system used for testing practice. The project deliberately injects some typical Bugs for testers to practice Bug discovery and verification.&lt;/p>
&lt;h2 id="project-features">Project Features
&lt;/h2>&lt;ul>
&lt;li>
&lt;p>Complete basic functions: implements basic functions such as adding, deleting, modifying, and querying books&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Typical Bug injection: contains multiple common problem scenarios&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Simple tech stack: uses a mainstream but lightweight technology combination&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Suitable for testing practice: diverse Bug types with clear reproduction steps&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="usage">Usage
&lt;/h2>&lt;p>Switch to different sprint branches and test against the requirements of each branch&lt;/p>
&lt;h2 id="notes">Notes
&lt;/h2>&lt;ul>
&lt;li>
&lt;p>This project is mainly for testing practice and is not recommended for production environments&lt;/p>
&lt;/li>
&lt;li>
&lt;p>All Bugs are deliberately injected for testing practice&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Bug locations are not marked in the project code; testers need to discover them on their own&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="testing-objectives">Testing Objectives
&lt;/h2>&lt;ol>
&lt;li>
&lt;p>Verify whether all injected Bugs can be reproduced&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Practice writing Bug reports&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Become familiar with common Web application problems&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Improve test case design skills&lt;/p>
&lt;/li>
&lt;/ol></description></item><item><title>The Two Sides of Applying Docker in Test Automation</title><link>https://chengxiaqiucao.github.io/en/post/095-docker%E5%9C%A8%E8%87%AA%E5%8A%A8%E5%8C%96/</link><pubDate>Sat, 24 May 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/095-docker%E5%9C%A8%E8%87%AA%E5%8A%A8%E5%8C%96/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/095-docker%E5%9C%A8%E8%87%AA%E5%8A%A8%E5%8C%96/Docker%E8%87%AA%E5%8A%A8%E5%8C%96.webp" alt="Featured image of post The Two Sides of Applying Docker in Test Automation" />&lt;h2 id="preface">Preface
&lt;/h2>&lt;p>Test automation is an indispensable part of software development today. To ensure consistency of the test environment, simplify configuration, and speed up test feedback, Docker technology is widely applied in test automation frameworks for containerized packaging.&lt;/p>
&lt;p>The common consensus is that once a test suite is Dockerized, it achieves the ideal state of &lt;strong>&amp;ldquo;build once, run anywhere&amp;rdquo;&lt;/strong>, completely eliminating the test uncertainty caused by environmental differences.&lt;/p>
&lt;p>In real engineering practice, however, can Dockerization truly guarantee perfect consistency of test execution? In this article we will take a deeper look at the promises and the reality of Docker in test automation, uncover the key factors that can lead to the &amp;ldquo;illusion of consistency&amp;rdquo;, and offer corresponding mitigation strategies.&lt;/p>
&lt;h2 id="dockers-promise---environment-packaging-and-consistency">Docker&amp;rsquo;s Promise - Environment Packaging and Consistency
&lt;/h2>&lt;p>Docker&amp;rsquo;s core value lies in using an image to package the complete runtime environment of an application (the operating system layer, runtime, libraries, tools, code, and configuration). Its workflow is typically as follows:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Build the image&lt;/strong>: In a development environment (such as a developer&amp;rsquo;s local PC), define dependency installation and configuration steps through a Dockerfile, and build an image containing the test suite and its runtime environment.&lt;/li>
&lt;li>&lt;strong>Distribute the image&lt;/strong>: Push the built image to an image registry (such as Docker Hub or Artifactory).&lt;/li>
&lt;li>&lt;strong>Run the container&lt;/strong>: In the target environment (a CI/CD pipeline, another developer&amp;rsquo;s machine, a pre-production environment, etc.), pull the image and instantiate it as a container to execute the tests.&lt;/li>
&lt;/ol>
&lt;p>In theory, this flow should ensure that regardless of the specific configuration of the underlying host, the test execution environment inside the container always stays consistent, thereby eliminating the classic developer problem of &lt;strong>&amp;ldquo;it works on my machine&amp;rdquo;&lt;/strong> and achieving reliable reproduction of test results.&lt;/p>
&lt;h2 id="the-reality---an-illusion-of-consistency">The Reality - An Illusion of Consistency
&lt;/h2>&lt;p>Ideals are rich, reality is lean. Although Docker provides powerful environment isolation, the following factors can still break the absolute consistency of tests and create an &amp;ldquo;illusion&amp;rdquo;:&lt;/p>
&lt;h3 id="cross-platform-host-architecture-differences">Cross-Platform Host Architecture Differences
&lt;/h3>&lt;p>An image built on an x86 host, when run on an ARM-based CI node (such as Apple Silicon M1/M2), can cause binaries that depend on specific CPU instruction sets, or Python packages containing C extensions, to malfunction or crash, so that tests passing locally fail in CI.&lt;/p>
&lt;blockquote>
&lt;p>Reason: Docker containers share the host&amp;rsquo;s kernel. The instruction sets of different CPU architectures (x86_64 vs arm64) are incompatible.&lt;/p>&lt;/blockquote>
&lt;h4 id="how-to-solve-it">How to Solve It?
&lt;/h4>&lt;ul>
&lt;li>&lt;strong>Multi-architecture image builds&lt;/strong>: Use the &lt;code>docker buildx&lt;/code> tool to build images that support multiple platforms (such as linux/amd64, linux/arm64).&lt;/li>
&lt;li>&lt;strong>Explicitly specify the platform&lt;/strong>: When running or building, force the target platform via the &lt;code>--platform&lt;/code> parameter (e.g., &lt;code>docker run --platform linux/amd64 my-test-image&lt;/code>).&lt;/li>
&lt;/ul>
&lt;h3 id="external-dependencies">External Dependencies
&lt;/h3>&lt;p>The test container may run perfectly well, but if a test case needs to access real services outside the container (a database, an API, S3, or internal systems reachable only via VPN), then test results can fluctuate due to the status of those external services, network latency, DNS resolution differences, firewall rules, or VPN connection state.&lt;/p>
&lt;blockquote>
&lt;p>Reason: What Docker containerizes is the test suite itself, not all the external systems it depends on. Network requests break through the container&amp;rsquo;s isolation boundary.&lt;/p>&lt;/blockquote>
&lt;h4 id="how-to-solve-it-1">How to Solve It?
&lt;/h4>&lt;ul>
&lt;li>&lt;strong>Containerize dependencies&lt;/strong>: Use Docker Compose to dynamically spin up the required external services (such as a database or a Mock server) as separate containers at test runtime, and establish an internal network connection with the test container.&lt;/li>
&lt;li>&lt;strong>Mock/Stub techniques&lt;/strong>: Widely apply Mock and Stub techniques in unit and integration tests to replace real external dependency calls.&lt;/li>
&lt;li>&lt;strong>Network environment control&lt;/strong>: Strictly manage the test environment&amp;rsquo;s network configuration (DNS, proxies, firewalls) to ensure predictability.&lt;/li>
&lt;/ul>
&lt;h3 id="host-operating-system-differences">Host Operating System Differences
&lt;/h3>&lt;p>Volume mount operations or network access (&lt;code>localhost&lt;/code>) that work fine on a Linux host can, on macOS or Windows (via Docker Desktop), produce file permission errors, broken symbolic links, line-ending (CRLF vs LF) issues, failed &lt;code>inotify&lt;/code> event watching, or ambiguity in what &lt;code>localhost&lt;/code> points to.&lt;/p>
&lt;blockquote>
&lt;p>Reason: Although the OS inside the container is consistent, the mechanisms by which Docker interacts with the host OS differ:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>File volume mounts&lt;/strong>: These involve mapping the host file system to the container file system, and different OSes support file permissions, metadata, and event notifications differently.&lt;/li>
&lt;li>&lt;strong>Network model&lt;/strong>: On Linux, container networking is usually more directly integrated; on macOS/Windows, Docker Desktop uses a VM bridge, and accessing host services requires the special hostname &lt;code>host.docker.internal&lt;/code> instead of &lt;code>localhost&lt;/code>.&lt;/li>
&lt;/ul>&lt;/blockquote>
&lt;h4 id="how-to-solve-it-2">How to Solve It?
&lt;/h4>&lt;ul>
&lt;li>&lt;strong>Understand platform differences&lt;/strong>: Be clearly aware that Docker is not entirely OS-agnostic and that its behavior is influenced by the host.&lt;/li>
&lt;li>&lt;strong>Use volume mounts cautiously&lt;/strong>: Avoid having core test logic depend heavily on host volume mounts, especially for write operations (such as generating reports or caches). Prefer in-container paths or the copy (&lt;code>COPY&lt;/code>) mechanism. If a mount is necessary, pay attention to file permissions and line-ending issues.&lt;/li>
&lt;li>&lt;strong>Use the correct network access method&lt;/strong>: When accessing host services from inside a container, consistently use &lt;code>host.docker.internal&lt;/code> (Mac/Windows) or understand the service access rules under Docker network modes (bridge/host) (Compose service names). Avoid hardcoding &lt;code>localhost&lt;/code>.&lt;/li>
&lt;/ul>
&lt;h3 id="resource-constraints">Resource Constraints
&lt;/h3>&lt;p>Tests pass on a well-resourced local development machine (say, 16 cores and 32GB RAM), but when run on a resource-constrained CI node (where the CPU may be throttled, memory may be insufficient, or resources are shared with other tasks), tests fail or become flaky due to timeouts and resource contention (CPU, IO).&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Reason&lt;/strong>: Docker containers share the host&amp;rsquo;s physical resources (CPU, memory, disk IO, network bandwidth). CI environments usually have lower resource quotas than development machines and are subject to contention.&lt;/p>&lt;/blockquote>
&lt;h4 id="how-to-solve-it-3">How to Solve It?
&lt;/h4>&lt;ul>
&lt;li>&lt;strong>Resource limits and monitoring&lt;/strong>: Set explicit resource limits (&lt;code>--cpus&lt;/code>, &lt;code>--memory&lt;/code>) for the test container in the Docker run command or Compose file to bring it closer to the CI environment. Monitor resource usage on the CI node.&lt;/li>
&lt;li>&lt;strong>Performance optimization&lt;/strong>: Optimize test cases and the framework itself to reduce resource consumption (e.g., controlling parallelism, avoiding memory leaks, optimizing I/O operations).&lt;/li>
&lt;li>&lt;strong>Choose a matching CI environment&lt;/strong>: Ensure the CI environment&amp;rsquo;s baseline resource configuration meets the minimum requirements for running the tests.&lt;/li>
&lt;/ul>
&lt;h3 id="mutable-dependencies-and-version-drift---the-hidden-risk-of-the-latest-tag">Mutable Dependencies and Version Drift - The Hidden Risk of the &amp;ldquo;latest&amp;rdquo; Tag
&lt;/h3>&lt;p>During image builds, using a base image tag like &lt;code>FROM python:latest&lt;/code>, or not strictly locking dependency versions with &lt;code>pip install -r requirements.txt&lt;/code> (without using &lt;code>pip freeze&lt;/code> or a lock file), can cause later builds to introduce incompatibilities or bugs due to unexpected upgrades of underlying dependencies (the Python interpreter, libraries), undermining test stability.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Reason&lt;/strong>: A dependency&amp;rsquo;s &amp;ldquo;latest&amp;rdquo; tag or an unlocked version number will point to a new version over time, introducing uncertainty.&lt;/p>&lt;/blockquote>
&lt;h4 id="how-to-solve-it-4">How to Solve It?
&lt;/h4>&lt;ul>
&lt;li>&lt;strong>Strict version locking&lt;/strong>: In the Dockerfile, use a base image tag with a definite version (such as &lt;code>FROM python:3.11-slim&lt;/code>). Use a lock file (such as &lt;code>requirements.txt&lt;/code> with an explicit version for each dependency, or &lt;code>poetry.lock&lt;/code>/&lt;code>Pipfile.lock&lt;/code>) to manage dependencies.&lt;/li>
&lt;li>&lt;strong>Reproducible builds&lt;/strong>: Ensure that every build, based on the same lock file, produces a completely identical image. Periodically and deliberately update dependency versions and re-test to verify.&lt;/li>
&lt;/ul>
&lt;h2 id="a-rational-view-of-dockers-value-and-engineering-practice">A Rational View of Docker&amp;rsquo;s Value and Engineering Practice
&lt;/h2>&lt;p>Despite all the problems above, we still &lt;strong>should not deny the tremendous value of Docker in test automation&lt;/strong>. In environment standardization, simplifying dependency management, and making CI/CD pipelines easier to manage, it still has irreplaceable advantages.&lt;/p>
&lt;p>So when applying Docker, the key is to understand: &lt;strong>Docker is a powerful tool for achieving consistency, but it is not a one-and-for-all &amp;ldquo;silver bullet&amp;rdquo;&lt;/strong>. Technology only delivers its value through sound engineering practices and effective constraints!&lt;/p>
&lt;h2 id="summary">&lt;strong>Summary&lt;/strong>
&lt;/h2>&lt;p>Docker has built a sturdy &amp;ldquo;fence&amp;rdquo; around the consistency of test automation environments, greatly improving the credibility and efficiency of testing. Yet that &amp;ldquo;fence&amp;rdquo; is not airtight.&lt;/p>
&lt;p>Host architecture differences, the intrusion of external dependencies, OS interaction characteristics, resource contention, and dependency version drift can all quietly erode the expected absolute consistency.&lt;/p>
&lt;p>Achieving truly reliable Dockerized test automation requires not only skillful use of Docker itself, but also rigorous engineering practice - defining environment boundaries, strict dependency management, optimized resource usage, and continuous monitoring and improvement. Only in this way can we effectively dispel the &amp;ldquo;illusion of consistency&amp;rdquo; and let Docker truly become a solid cornerstone for software quality.&lt;/p>
&lt;p>So the next time we hear &amp;ldquo;&lt;strong>No problem, it has already been containerized with Docker&lt;/strong>&amp;rdquo;, it is worth asking a few more questions:&lt;/p>
&lt;ul>
&lt;li>What architecture does it run on?&lt;/li>
&lt;li>Are the dependencies locked?&lt;/li>
&lt;li>How are network and file access handled?&lt;/li>
&lt;li>Are the resources sufficient?&lt;/li>
&lt;/ul>
&lt;p>Know yourself and know your enemy, and you can plan with confidence.&lt;/p>
&lt;hr></description></item><item><title>AI Tips, Generate Images with Local DeepSeek Too</title><link>https://chengxiaqiucao.github.io/en/post/094-deepseek%E7%94%9F%E5%9B%BE/</link><pubDate>Sun, 18 May 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/094-deepseek%E7%94%9F%E5%9B%BE/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/094-deepseek%E7%94%9F%E5%9B%BE/snap_20250613.webp" alt="Featured image of post AI Tips, Generate Images with Local DeepSeek Too" />&lt;blockquote>
&lt;p>We all know that DeepSeek is a text model and has no ability to generate images. Meanwhile, the various online image-generation AIs are either paid or subject to quota limits. Here I would like to share with you a completely free AI image-generation trick using a locally deployed DeepSeek.&lt;/p>&lt;/blockquote>
&lt;h2 id="the-ai-image-generation-api">The AI Image Generation API
&lt;/h2>&lt;p>DeepSeek itself certainly cannot generate images at present, but GitHub, that treasure trove, is naturally full of surprises. The image-generation tool introduced in this article comes from a German AI startup and supports text-to-image, text-to-audio, and other functions.&lt;/p>
&lt;h3 id="introduction-to-pollinationsai">Introduction to pollinations.ai
&lt;/h3>&lt;p>This project supports image generation through a basic Restful API interface.&lt;/p>
&lt;p>Open-source project address:&lt;/p>
&lt;p>&lt;a class="link" href="https://github.com/pollinations/pollinations" target="_blank" rel="noopener"
>https://github.com/pollinations/pollinations&lt;/a>&lt;/p>
&lt;p>Official website:&lt;/p>
&lt;p>&lt;a class="link" href="https://pollinations.ai/" target="_blank" rel="noopener"
>https://pollinations.ai/&lt;/a>&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/094-deepseek%E7%94%9F%E5%9B%BE/snap_20250613_hu_12aff93a37c8b7cf.webp"
width="1024"
height="397"
srcset="https://chengxiaqiucao.github.io/post/094-deepseek%E7%94%9F%E5%9B%BE/snap_20250613_hu_477842d19bb97f72.webp 480w, https://chengxiaqiucao.github.io/post/094-deepseek%E7%94%9F%E5%9B%BE/snap_20250613_hu_12aff93a37c8b7cf.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="258"
data-flex-basis="619px"
>
&lt;/p>
&lt;p>The official website may be plain, but it requires no registration or keys, is open source and free—simply wonderful.&lt;/p>
&lt;h3 id="api-definition">API Definition
&lt;/h3>&lt;p>The API for generating images is the most basic &lt;code>get&lt;/code> method:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">GET https://image.pollinations.ai/prompt/{prompt}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Parameters supported by the API:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: center">Parameter&lt;/th>
&lt;th style="text-align: center">Required&lt;/th>
&lt;th style="text-align: center">Description&lt;/th>
&lt;th style="text-align: center">Default&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: center">&lt;code>prompt&lt;/code>&lt;/td>
&lt;td style="text-align: center">Yes&lt;/td>
&lt;td style="text-align: center">Image generation prompt&lt;/td>
&lt;td style="text-align: center">&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: center">&lt;code>model&lt;/code>&lt;/td>
&lt;td style="text-align: center">No&lt;/td>
&lt;td style="text-align: center">Image generation model used&lt;/td>
&lt;td style="text-align: center">&lt;code>flux&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: center">&lt;code>seed&lt;/code>&lt;/td>
&lt;td style="text-align: center">No&lt;/td>
&lt;td style="text-align: center">Random seed&lt;/td>
&lt;td style="text-align: center">&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: center">&lt;code>width&lt;/code>&lt;/td>
&lt;td style="text-align: center">No&lt;/td>
&lt;td style="text-align: center">Image width (pixels)&lt;/td>
&lt;td style="text-align: center">1024&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: center">&lt;code>height&lt;/code>&lt;/td>
&lt;td style="text-align: center">No&lt;/td>
&lt;td style="text-align: center">Image height (pixels)&lt;/td>
&lt;td style="text-align: center">1024&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: center">&lt;code>nologo&lt;/code>&lt;/td>
&lt;td style="text-align: center">No&lt;/td>
&lt;td style="text-align: center">Whether to keep the pollinations logo&lt;/td>
&lt;td style="text-align: center">&lt;code>false&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: center">&lt;code>private&lt;/code>&lt;/td>
&lt;td style="text-align: center">No&lt;/td>
&lt;td style="text-align: center">Whether to make the generated image public&lt;/td>
&lt;td style="text-align: center">&lt;code>false&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: center">&lt;code>enhance&lt;/code>&lt;/td>
&lt;td style="text-align: center">No&lt;/td>
&lt;td style="text-align: center">Whether to use an LLM to enhance the prompt&lt;/td>
&lt;td style="text-align: center">&lt;code>false&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: center">&lt;code>safe&lt;/code>&lt;/td>
&lt;td style="text-align: center">No&lt;/td>
&lt;td style="text-align: center">Adult content&lt;/td>
&lt;td style="text-align: center">&lt;code>false&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: center">&lt;code>transparent&lt;/code>&lt;/td>
&lt;td style="text-align: center">No&lt;/td>
&lt;td style="text-align: center">Transparent background (only effective for the gptimage model).&lt;/td>
&lt;td style="text-align: center">&lt;code>false&lt;/code>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>List of supported models:&lt;/p>
&lt;ul>
&lt;li>&lt;code>flux&lt;/code> (base model)&lt;/li>
&lt;li>&lt;code>flux-pro&lt;/code> (enhanced effect)&lt;/li>
&lt;li>&lt;code>flux-realism&lt;/code> (realistic style)&lt;/li>
&lt;li>&lt;code>flux-anime&lt;/code> (anime style)&lt;/li>
&lt;li>&lt;code>flux-3d&lt;/code> (3D style)&lt;/li>
&lt;li>&lt;code>flux-cablyai&lt;/code> (unknown)&lt;/li>
&lt;li>&lt;code>turbo&lt;/code> (fast generation)&lt;/li>
&lt;/ul>
&lt;p>The http get method can actually be requested and rendered directly through html, which gives us the opportunity to complete image generation based on DeepSeek. In other words, we can define rules that let DeepSeek generate the required prompt and present the image generated by the pollinations api in html according to the HTML format.&lt;/p>
&lt;h2 id="local-deepseek-and-cherry-studio-configuration">Local DeepSeek and cherry studio Configuration
&lt;/h2>&lt;p>The method of deploying DeepSeek locally via Ollama and interacting with it through cherry studio was described in detail in a previous article [], so I will not repeat it here.&lt;/p>
&lt;p>After running the DeepSeek model locally, for example &lt;code>deepseek-r1:14b&lt;/code>, open cherry studio, add a role such as Image Generation Assistant, and set its system prompt to define the relevant rules (see the end of the article for the specific prompt).&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/094-deepseek%E7%94%9F%E5%9B%BE/snap_20250613-1_hu_2633b797f6c08f4d.webp"
width="1024"
height="541"
srcset="https://chengxiaqiucao.github.io/post/094-deepseek%E7%94%9F%E5%9B%BE/snap_20250613-1_hu_c26e1ed399733c64.webp 480w, https://chengxiaqiucao.github.io/post/094-deepseek%E7%94%9F%E5%9B%BE/snap_20250613-1_hu_2633b797f6c08f4d.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="189"
data-flex-basis="454px"
>
&lt;/p>
&lt;p>Next, let&amp;rsquo;s test it by entering the following in cherry studio:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">Autumn, at the foot of an ancient city wall, a clump of wild grass swaying in the wind, anime style, 16:9
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>After some thinking, DeepSeek successfully generated a &lt;strong>Picture of Autumn Grass Beneath the City Wall&lt;/strong>.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/094-deepseek%E7%94%9F%E5%9B%BE/snap_20250613-2_hu_6f1c5fab42bbbcb9.webp"
width="1024"
height="1207"
srcset="https://chengxiaqiucao.github.io/post/094-deepseek%E7%94%9F%E5%9B%BE/snap_20250613-2_hu_96007193e2897db3.webp 480w, https://chengxiaqiucao.github.io/post/094-deepseek%E7%94%9F%E5%9B%BE/snap_20250613-2_hu_6f1c5fab42bbbcb9.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="84"
data-flex-basis="203px"
>
&lt;/p>
&lt;p>Give it a try, everyone~~&lt;/p>
&lt;h3 id="appendix">Appendix:
&lt;/h3>&lt;p>Prompt rule-setting template:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-mysql" data-lang="mysql">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">#Role: You are a professional image creation assistant.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">#Skills: Based on a simple description entered by the user, generate a &amp;#34;detailed description&amp;#34; of a complete picture.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">#Rules:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Insert&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">simple&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">description&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">entered&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">by&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">user&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">into&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">{&lt;/span>&lt;span class="n">user_prompt&lt;/span>&lt;span class="err">}&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">part&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">Output&lt;/span>&lt;span class="p">].&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Make&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">generated&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;detailed description&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">as&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">comprehensive&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rich&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">in&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">detail&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">as&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">possible&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">supplementing&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">it&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">from&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">professional&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">image&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">generation&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">perspective&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">with&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">aspects&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">such&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">as&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">lighting&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">composition&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">materials&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">viewpoint&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">color&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rendering&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">method&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Insert&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;detailed description&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">into&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">{&lt;/span>&lt;span class="n">ai_chinese_prompt&lt;/span>&lt;span class="err">}&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">part&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">Output&lt;/span>&lt;span class="p">].&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Translate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;detailed description&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">completely&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">accurately&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">into&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">English&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">insert&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">it&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">into&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">{&lt;/span>&lt;span class="n">ai_english_prompt&lt;/span>&lt;span class="err">}&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">part&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">Output&lt;/span>&lt;span class="p">].&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">If&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">user&lt;/span>&lt;span class="s1">&amp;#39;s description contains height information, insert it directly into the {width} part of [Output]; otherwise insert the default value 1280.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">6. If the user&amp;#39;&lt;/span>&lt;span class="n">s&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">description&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">contains&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">width&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">information&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">insert&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">it&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">directly&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">into&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">{&lt;/span>&lt;span class="n">height&lt;/span>&lt;span class="err">}&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">part&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">Output&lt;/span>&lt;span class="p">];&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">otherwise&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">insert&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">default&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">value&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">1280&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">If&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ratio&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">appears&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">it&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">means&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">width&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">height&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">with&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">width&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">defaulting&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">to&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">1280&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">calculate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">height&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">from&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ratio&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">insert&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">it&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">into&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">{&lt;/span>&lt;span class="n">height&lt;/span>&lt;span class="err">}&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">part&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">Output&lt;/span>&lt;span class="p">].&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">8&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Randomly&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">generate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">an&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kt">integer&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">insert&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">it&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">into&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">{&lt;/span>&lt;span class="n">seed&lt;/span>&lt;span class="err">}&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">part&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">Output&lt;/span>&lt;span class="p">].&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">9&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Select&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">corresponding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">model&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">based&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">on&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">user&lt;/span>&lt;span class="s1">&amp;#39;s description of the picture style. If the user has not specified one, randomly choose a model from the 7 models below and insert it into the {model} part of [Output].
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">- `flux` (base model)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">- `flux-pro` (enhanced effect)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">- `flux-realism` (realistic style)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">- `flux-anime` (anime style)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">- `flux-3d` (3D style)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">- `flux-cablyai` (unknown)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">- `turbo` (fast generation)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">10. Render the output result directly; do not display it as a code block.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">#Output:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">&amp;lt;html&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> &amp;lt;title&amp;gt;Image Generator&amp;lt;/title&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> &amp;lt;body&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> &amp;lt;h2&amp;gt;{ai_chinese_prompt}&amp;lt;/h2&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> &amp;lt;h4&amp;gt;{ai_english_prompt}&amp;lt;/h4&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> &amp;lt;img
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> src=&amp;#34;https://image.pollinations.ai/prompt/{ai_english_prompt}?width={width}&amp;amp;height={height}&amp;amp;seed={seed}&amp;amp;enhance=true&amp;amp;private=true&amp;amp;nologo=true&amp;amp;safe=false&amp;amp;model={model}&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> alt=&amp;#34;{user_prompt}&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> /&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> &amp;lt;/body&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">&amp;lt;/html&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div></description></item><item><title>W3C ARIA Roles and Their Role in AI-Driven Test Automation</title><link>https://chengxiaqiucao.github.io/en/post/084-aria%E4%BB%8B%E7%BB%8D/</link><pubDate>Sun, 27 Apr 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/084-aria%E4%BB%8B%E7%BB%8D/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/084-aria%E4%BB%8B%E7%BB%8D/-20250417.webp" alt="Featured image of post W3C ARIA Roles and Their Role in AI-Driven Test Automation" />&lt;h2 id="preface">Preface
&lt;/h2>&lt;p>In the field of test automation, the hottest automation framework today is undoubtedly &lt;code>Playwright&lt;/code>. When it comes to page element location — extremely critical in test automation — compared with traditional tools such as &lt;code>Selenium&lt;/code>, it introduces a new element-location method, &lt;code>getByRole&lt;/code>, which fully leverages the ARIA Roles objects defined by the W3C to identify elements. While improving the flexibility and efficiency of element identification, it simultaneously verifies the accessibility compliance of the page. For example:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Locate the button named &amp;#34;Search&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;搜索&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">click&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Locate the checkbox and check it
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;checkbox&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;同意条款&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">check&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Locate the text input and fill in content
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;textbox&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;用户名&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">fill&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;testuser&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Locate the dropdown and select an option
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;combobox&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;国家&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">selectOption&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;中国&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Today, AI is increasingly taking part in our daily work. As shown in the earlier 【】 article, driving a page through an &lt;code>mcp server&lt;/code> to complete automated testing with AI has become quite feasible in practice. After that article, many readers remained skeptical about how AI actually recognizes and locates page elements, drives execution through tools, and whether the results in real use can meet expectations.&lt;/p>
&lt;p>In fact, the &lt;code>ARIA&lt;/code> standard within the &lt;code>W3C&lt;/code> web specifications plays an important role here: it presents page objects to AI in a structured form, making it easier for AI to analyze the page. In this article, we will explore the &lt;code>ARIA&lt;/code> standard and its important role in AI-driven test automation.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/084-aria%E4%BB%8B%E7%BB%8D/-20250417_hu_2f6c810144873078.webp"
width="1024"
height="374"
srcset="https://chengxiaqiucao.github.io/post/084-aria%E4%BB%8B%E7%BB%8D/-20250417_hu_cd314db8f3c0cf27.webp 480w, https://chengxiaqiucao.github.io/post/084-aria%E4%BB%8B%E7%BB%8D/-20250417_hu_2f6c810144873078.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="274"
data-flex-basis="657px"
>
&lt;/p>
&lt;h2 id="what-is-aria">What is ARIA?
&lt;/h2>&lt;h3 id="definition">Definition
&lt;/h3>&lt;p>&lt;strong>WAI-ARIA&lt;/strong> (Web Accessibility Initiative – Accessible Rich Internet Applications), i.e. the &lt;strong>Web Accessibility Initiative – Accessible Rich Internet Applications standard&lt;/strong>, is a specification that enables web applications to better support use by people with disabilities.&lt;/p>
&lt;p>&lt;strong>ARIA Roles&lt;/strong> are a set of attributes defined in the W3C &lt;strong>WAI-ARIA&lt;/strong> specification, used to describe the function and purpose of web elements and to help assistive technologies (such as screen readers) understand and convey page content more accurately. **ARIA Roles ** are added to HTML elements through the &lt;code>role&lt;/code> attribute; for example, &lt;code>&amp;lt;div role=&amp;quot;button&amp;quot;&amp;gt;&lt;/code> indicates that the div element should be treated as a button.&lt;/p>
&lt;h3 id="evolution-of-the-standard-and-the-advantages-of-aria">Evolution of the Standard and the Advantages of ARIA
&lt;/h3>&lt;p>This standard has gone through three important stages of development:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>2008&lt;/strong>: W3C first released ARIA 1.0&lt;/li>
&lt;li>&lt;strong>2014&lt;/strong>: ARIA 1.1 introduced new roles such as &lt;code>searchbox&lt;/code>, &lt;code>switch&lt;/code>&lt;/li>
&lt;li>&lt;strong>2021&lt;/strong>: ARIA 1.2 added &lt;code>comment&lt;/code>, &lt;code>mark&lt;/code>, and other roles related to digital content&lt;/li>
&lt;/ul>
&lt;p>Comparison with traditional UI test automation:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Dimension&lt;/th>
&lt;th>Traditional UI Testing&lt;/th>
&lt;th>ARIA-Based Testing&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Element Identification Basis&lt;/td>
&lt;td>DOM Structure / Visual Features&lt;/td>
&lt;td>Semantic Roles / Functional Attributes&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Maintenance Cost&lt;/td>
&lt;td>High (frequent updates as UI changes)&lt;/td>
&lt;td>Low (role definitions are more stable)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Cross-Platform Consistency&lt;/td>
&lt;td>Depends on the rendering engine&lt;/td>
&lt;td>Standardized behavior&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Accessibility Support&lt;/td>
&lt;td>Requires additional verification&lt;/td>
&lt;td>Built-in support&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="categories-of-aria-roles">Categories of ARIA Roles
&lt;/h3>&lt;p>According to the W3C specification, ARIA Roles can be divided into the following major categories:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>&lt;strong>Widget Roles&lt;/strong>: describe interactive UI components&lt;/p>
&lt;ul>
&lt;li>&lt;code>button&lt;/code>: a clickable button&lt;/li>
&lt;li>&lt;code>checkbox&lt;/code>: a checkbox&lt;/li>
&lt;li>&lt;code>radio&lt;/code>: a radio button&lt;/li>
&lt;li>&lt;code>textbox&lt;/code>: a text input box&lt;/li>
&lt;li>&lt;code>combobox&lt;/code>: a dropdown combo box&lt;/li>
&lt;li>&lt;code>slider&lt;/code>: a slider control&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Document Structure Roles&lt;/strong>: describe the structure of page content&lt;/p>
&lt;ul>
&lt;li>&lt;code>heading&lt;/code>: a heading (alternative to h1-h6)&lt;/li>
&lt;li>&lt;code>list&lt;/code>/&lt;code>listitem&lt;/code>: a list and list items&lt;/li>
&lt;li>&lt;code>table&lt;/code>/&lt;code>row&lt;/code>/&lt;code>cell&lt;/code>: table structure&lt;/li>
&lt;li>&lt;code>img&lt;/code>: an image&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Landmark Roles&lt;/strong>: identify the main regions of a page&lt;/p>
&lt;ul>
&lt;li>&lt;code>banner&lt;/code>: page header&lt;/li>
&lt;li>&lt;code>navigation&lt;/code>: navigation region&lt;/li>
&lt;li>&lt;code>main&lt;/code>: main content&lt;/li>
&lt;li>&lt;code>search&lt;/code>: search region&lt;/li>
&lt;li>&lt;code>contentinfo&lt;/code>: footer information&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Live Region Roles&lt;/strong>: regions for dynamic content updates&lt;/p>
&lt;ul>
&lt;li>&lt;code>alert&lt;/code>: important information that needs immediate notification&lt;/li>
&lt;li>&lt;code>status&lt;/code>: feedback on operation status&lt;/li>
&lt;li>&lt;code>timer&lt;/code>: a timer or counter&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;p>In addition to the basic Roles, advanced roles commonly used in modern web applications also include:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Composite component roles&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;tree&amp;#34;&lt;/span> &lt;span class="na">aria-label&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;文件浏览器&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;treeitem&amp;#34;&lt;/span> &lt;span class="na">aria-expanded&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;true&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Documents
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;group&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;treeitem&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>工作文档.docx&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>&lt;strong>Real-time communication roles&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;feed&amp;#34;&lt;/span> &lt;span class="na">aria-busy&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;false&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">article&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;article&amp;#34;&lt;/span> &lt;span class="na">aria-posinset&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;1&amp;#34;&lt;/span> &lt;span class="na">aria-setsize&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;10&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>...&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">article&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>&lt;strong>Drag-and-drop roles&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;draggable&amp;#34;&lt;/span> &lt;span class="na">aria-grabbed&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;false&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Draggable item&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;droppable&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;/ul>
&lt;h2 id="the-core-role-of-aria-in-ai-driven-testing">The Core Role of ARIA in AI-Driven Testing
&lt;/h2>&lt;h3 id="enhanced-semantic-understanding">Enhanced Semantic Understanding
&lt;/h3>&lt;p>An AI test system, through the semantic network built by ARIA roles, can understand UI functions more accurately:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">graph TD
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> A[Raw DOM] --&amp;gt; B(Visual Feature Analysis)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> A --&amp;gt; C(ARIA Role Parsing)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> C --&amp;gt; D[Semantic Understanding Layer]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> B --&amp;gt; D
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> D --&amp;gt; E[Component Function Classification]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> D --&amp;gt; F[Operation Intent Inference]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Typical application scenarios&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>Automatically identify unmarked required form fields (via &lt;code>aria-required&lt;/code>)&lt;/li>
&lt;li>Detect the priority of dynamic content updates (via &lt;code>aria-live&lt;/code> values &lt;code>polite&lt;/code>/&lt;code>assertive&lt;/code>)&lt;/li>
&lt;li>Identify the interaction boundaries of composite components (such as the modal scope of &lt;code>role=&amp;quot;dialog&amp;quot;&lt;/code>)&lt;/li>
&lt;/ul>
&lt;h3 id="intelligent-test-case-generation">Intelligent Test Case Generation
&lt;/h3>&lt;p>The ARIA-based AI test generation workflow:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>&lt;strong>Role graph construction&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">build_role_graph&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">page&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">graph&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">{}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">element&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">page&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">query_selector_all&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;[role]&amp;#39;&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">role&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">element&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">get_attribute&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;role&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">related&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">get_related_aria_attributes&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">element&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">graph&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">element&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">{&lt;/span>&lt;span class="s1">&amp;#39;role&amp;#39;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="n">role&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;attributes&amp;#39;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="n">related&lt;/span>&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="n">graph&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>&lt;strong>Test strategy matching&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>Button-type roles (&lt;code>button&lt;/code>, &lt;code>switch&lt;/code>) → click action sequences&lt;/li>
&lt;li>Input-type roles (&lt;code>textbox&lt;/code>, &lt;code>spinbutton&lt;/code>) → input validation tests&lt;/li>
&lt;li>Status-type roles (&lt;code>progressbar&lt;/code>, &lt;code>timer&lt;/code>) → dynamic monitoring tests&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Edge case derivation&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>When &lt;code>role=&amp;quot;combobox&amp;quot;&lt;/code> is detected but &lt;code>aria-controls&lt;/code> is missing&lt;/li>
&lt;li>When child items in &lt;code>role=&amp;quot;tablist&amp;quot;&lt;/code> do not have &lt;code>aria-selected&lt;/code> set correctly&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;h3 id="23-self-healing-test-maintenance">2.3 Self-Healing Test Maintenance
&lt;/h3>&lt;p>The self-healing test mechanism implemented by an AI system using ARIA:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">sequenceDiagram
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> Test Case-&amp;gt;&amp;gt;+AI Engine: Location failed (old selector)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> AI Engine-&amp;gt;&amp;gt;+DOM: Query elements with the same role
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> DOM--&amp;gt;&amp;gt;-AI Engine: Return candidate elements
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> AI Engine-&amp;gt;&amp;gt;+ARIA Analyzer: Validate name/state
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> ARIA Analyzer--&amp;gt;&amp;gt;-AI Engine: Best match result
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> AI Engine-&amp;gt;&amp;gt;Test Case: Update locator
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Expected effects&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>Reduced selector maintenance effort&lt;/li>
&lt;li>Lower false-positive rate compared with traditional methods&lt;/li>
&lt;li>Improved cross-platform test consistency&lt;/li>
&lt;/ul>
&lt;h2 id="synergy-between-aria-and-computer-vision-testing">Synergy Between ARIA and Computer Vision Testing
&lt;/h2>&lt;h3 id="31-multimodal-test-fusion">3.1 Multimodal Test Fusion
&lt;/h3>&lt;p>The advantages of combining ARIA and CV in modern AI test platforms:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Detection Dimension&lt;/th>
&lt;th>Information Provided by ARIA&lt;/th>
&lt;th>Supplementary Information from CV&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Element Function&lt;/td>
&lt;td>Explicit role definition&lt;/td>
&lt;td>Visual style verification&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Interaction State&lt;/td>
&lt;td>Attributes such as aria-pressed&lt;/td>
&lt;td>Actual rendered state&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Hierarchical Relationship&lt;/td>
&lt;td>Attributes such as aria-owns&lt;/td>
&lt;td>Spatial position relationship&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Dynamic Changes&lt;/td>
&lt;td>aria-live regions&lt;/td>
&lt;td>Pixel-level change detection&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;strong>Example collaborative workflow&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;span class="lnt">9
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">validate_accessible_button&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">element&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># ARIA verification&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">assert&lt;/span> &lt;span class="n">element&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">get_attribute&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;role&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">assert&lt;/span> &lt;span class="n">element&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">get_attribute&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;aria-label&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="ow">is&lt;/span> &lt;span class="ow">not&lt;/span> &lt;span class="kc">None&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># CV verification&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">screenshot&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">element&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">screenshot&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">cv_result&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">analyze_button_visuals&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">screenshot&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">assert&lt;/span> &lt;span class="n">cv_result&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;contrast_ratio&amp;#39;&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">&amp;gt;=&lt;/span> &lt;span class="mf">4.5&lt;/span> &lt;span class="c1"># WCAG AA standard&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="intelligent-accessibility-auditing">Intelligent Accessibility Auditing
&lt;/h3>&lt;p>Architecture of an AI-driven ARIA audit system:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">[Page Crawling Module]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> ↓
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">[ARIA Attribute Extractor]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> ↓
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">[Rule Engine]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── WCAG 2.1 rule set
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── Custom business rules
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">└── Machine-learning anomaly detection
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> ↓
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">[Fix Suggestion Generation]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── Automatic fix solutions
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">├── Design pattern recommendations
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">└── Code completion hints
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="ai-test-automation-application-scenarios">AI Test Automation Application Scenarios
&lt;/h2>&lt;h3 id="large-language-model-llm-integration">Large Language Model (LLM) Integration
&lt;/h3>&lt;p>The structured context that ARIA can provide to an LLM:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">Given the following ARIA context:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Currently focused element: role=&amp;#34;combobox&amp;#34;, aria-expanded=&amp;#34;false&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Related elements:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">*&lt;/span> role=&amp;#34;listbox&amp;#34; (hidden)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">*&lt;/span> role=&amp;#34;option&amp;#34; x3 (hidden)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Test action sequence generated by the LLM:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">1.&lt;/span> Trigger the expand action of the combobox
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">2.&lt;/span> Verify that the listbox visibility becomes true
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">3.&lt;/span> Get the option list and select the second item
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">4.&lt;/span> Verify that the combobox&amp;#39;s aria-activedescendant is updated
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="scriptless-test-automation">Scriptless Test Automation
&lt;/h3>&lt;p>Combining ARIA and MCP to achieve zero-code testing:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>&lt;strong>Recording phase&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>Listen for ARIA role changes across all interaction events&lt;/li>
&lt;li>Build an action-state transition graph&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Replay phase&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">replay_by_aria&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">flow&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">for&lt;/span> &lt;span class="n">step&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">flow&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">target&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">find_element_by_role_state&lt;/span>&lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">step&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;role&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">step&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;attributes&amp;#39;&lt;/span>&lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">execute_action&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">target&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">step&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;action&amp;#39;&lt;/span>&lt;span class="p">])&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">validate_aria_states&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">step&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;expected_states&amp;#39;&lt;/span>&lt;span class="p">])&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;/ol>
&lt;h3 id="cross-device-test-adaptation">Cross-Device Test Adaptation
&lt;/h3>&lt;p>Mapping strategies for ARIA roles across different devices:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Desktop Role&lt;/th>
&lt;th>Mobile Equivalent Mode&lt;/th>
&lt;th>AI Handling Strategy&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>tablist&lt;/td>
&lt;td>Bottom navigation bar&lt;/td>
&lt;td>Automatic adaptation based on aria-orientation&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>tooltip&lt;/td>
&lt;td>Long-press hint&lt;/td>
&lt;td>Automatic adjustment of interaction timeout&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>slider&lt;/td>
&lt;td>Touch slider&lt;/td>
&lt;td>Step size optimized based on screen size&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="future-directions">Future Directions
&lt;/h2>&lt;h3 id="deep-integration-of-aria-and-testing-ai">Deep Integration of ARIA and Testing AI
&lt;/h3>&lt;ul>
&lt;li>Role-driven autonomous exploratory testing&lt;/li>
&lt;li>Transfer learning based on role similarity&lt;/li>
&lt;/ul>
&lt;h3 id="integration-with-other-emerging-test-technologies">Integration with Other Emerging Test Technologies
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">graph LR
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> A[ARIA Semantics] --&amp;gt; B[VR/AR Testing]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> A --&amp;gt; C[Voice Interaction Testing]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> A --&amp;gt; D[IoT Interface Testing]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="standardization-evolution">Standardization Evolution
&lt;/h3>&lt;p>The ARIA 2.0 specification currently being drafted will add:&lt;/p>
&lt;ul>
&lt;li>More fine-grained state descriptions&lt;/li>
&lt;li>Enhanced AI-assisted attributes&lt;/li>
&lt;li>Three-dimensional interface support&lt;/li>
&lt;/ul>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>The ARIA standard is becoming key infrastructure for intelligent test automation. The rich semantic layer it provides enables AI systems to understand the interaction logic of web applications much as humans do. As the W3C continues to refine the standard and the testing toolchain evolves, ARIA-based, AI-driven testing is bound to become a core pillar in the field of web test automation.&lt;/p>
&lt;hr>
&lt;h1 id="w3c-aria-roles-and-their-application-in-playwright-test-automation">W3C ARIA Roles and Their Application in Playwright Test Automation
&lt;/h1>&lt;p>As a test automation engineer, understanding and correctly applying ARIA (Accessible Rich Internet Applications) Roles from the W3C standard is essential for building accessible web applications and writing reliable automated test scripts. This article introduces the core concepts, categories, and best practices of ARIA Roles in detail, with a focus on how to effectively leverage these roles for element location and verification within the Playwright testing framework.&lt;/p>
&lt;h2 id="i-overview-of-aria-roles">I. Overview of ARIA Roles
&lt;/h2>&lt;h3 id="11-what-are-aria-roles">1.1 What Are ARIA Roles
&lt;/h3>&lt;p>ARIA Roles are a set of attributes defined in the W3C WAI-ARIA specification, used to describe the function and purpose of web elements and to help assistive technologies (such as screen readers) understand and convey page content more accurately. ARIA Roles are added to HTML elements through the &lt;code>role&lt;/code> attribute; for example, &lt;code>&amp;lt;div role=&amp;quot;button&amp;quot;&amp;gt;&lt;/code> indicates that the div element should be treated as a button.&lt;/p>
&lt;h3 id="12-the-importance-of-aria-roles">1.2 The Importance of ARIA Roles
&lt;/h3>&lt;p>In web test automation, ARIA Roles offer the following advantages:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Enhanced element semantics&lt;/strong>: provide clear semantics for custom controls or non-standard HTML elements&lt;/li>
&lt;li>&lt;strong>Improved test reliability&lt;/strong>: compared with fragile CSS selectors or XPath, role-based location is more stable&lt;/li>
&lt;li>&lt;strong>Accessibility testing support&lt;/strong>: verify whether the application complies with accessibility standards (WCAG)&lt;/li>
&lt;li>&lt;strong>Cross-browser consistency&lt;/strong>: ARIA Roles behave consistently across different browsers, reducing test discrepancies&lt;/li>
&lt;/ol>
&lt;h2 id="ii-categories-of-aria-roles-and-common-roles">II. Categories of ARIA Roles and Common Roles
&lt;/h2>&lt;h3 id="21-main-categories-of-aria-roles">2.1 Main Categories of ARIA Roles
&lt;/h3>&lt;p>According to the W3C specification, ARIA Roles can be divided into the following major categories:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>&lt;strong>Widget Roles&lt;/strong>: describe interactive UI components&lt;/p>
&lt;ul>
&lt;li>&lt;code>button&lt;/code>: a clickable button&lt;/li>
&lt;li>&lt;code>checkbox&lt;/code>: a checkbox&lt;/li>
&lt;li>&lt;code>radio&lt;/code>: a radio button&lt;/li>
&lt;li>&lt;code>textbox&lt;/code>: a text input box&lt;/li>
&lt;li>&lt;code>combobox&lt;/code>: a dropdown combo box&lt;/li>
&lt;li>&lt;code>slider&lt;/code>: a slider control&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Document Structure Roles&lt;/strong>: describe the structure of page content&lt;/p>
&lt;ul>
&lt;li>&lt;code>heading&lt;/code>: a heading (alternative to h1-h6)&lt;/li>
&lt;li>&lt;code>list&lt;/code>/&lt;code>listitem&lt;/code>: a list and list items&lt;/li>
&lt;li>&lt;code>table&lt;/code>/&lt;code>row&lt;/code>/&lt;code>cell&lt;/code>: table structure&lt;/li>
&lt;li>&lt;code>img&lt;/code>: an image&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Landmark Roles&lt;/strong>: identify the main regions of a page&lt;/p>
&lt;ul>
&lt;li>&lt;code>banner&lt;/code>: page header&lt;/li>
&lt;li>&lt;code>navigation&lt;/code>: navigation region&lt;/li>
&lt;li>&lt;code>main&lt;/code>: main content&lt;/li>
&lt;li>&lt;code>search&lt;/code>: search region&lt;/li>
&lt;li>&lt;code>contentinfo&lt;/code>: footer information&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Live Region Roles&lt;/strong>: regions for dynamic content updates&lt;/p>
&lt;ul>
&lt;li>&lt;code>alert&lt;/code>: important information that needs immediate notification&lt;/li>
&lt;li>&lt;code>status&lt;/code>: feedback on operation status&lt;/li>
&lt;li>&lt;code>timer&lt;/code>: a timer or counter&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;h3 id="22-examples-of-common-aria-roles">2.2 Examples of Common ARIA Roles
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-html" data-lang="html">&lt;span class="line">&lt;span class="cl">&lt;span class="c">&amp;lt;!-- Button role --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;button&amp;#34;&lt;/span> &lt;span class="na">tabindex&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;0&amp;#34;&lt;/span> &lt;span class="na">aria-pressed&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;false&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Custom button&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c">&amp;lt;!-- Navigation region --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">nav&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;navigation&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">ul&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">li&lt;/span>&lt;span class="p">&amp;gt;&amp;lt;&lt;/span>&lt;span class="nt">a&lt;/span> &lt;span class="na">href&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;/&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>Home&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">a&lt;/span>&lt;span class="p">&amp;gt;&amp;lt;/&lt;/span>&lt;span class="nt">li&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">ul&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">nav&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c">&amp;lt;!-- Alert message --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;alert&amp;#34;&lt;/span> &lt;span class="na">aria-live&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;assertive&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> Your operation has been saved successfully
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c">&amp;lt;!-- Progress bar --&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">div&lt;/span> &lt;span class="na">role&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;progressbar&amp;#34;&lt;/span> &lt;span class="na">aria-valuenow&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;75&amp;#34;&lt;/span> &lt;span class="na">aria-valuemin&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;0&amp;#34;&lt;/span> &lt;span class="na">aria-valuemax&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;100&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&amp;lt;/&lt;/span>&lt;span class="nt">div&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="iii-aria-in-playwright">III. ARIA in Playwright
&lt;/h2>&lt;h3 id="31-element-location-based-on-aria-roles">3.1 Element Location Based on ARIA Roles
&lt;/h3>&lt;p>Playwright provides a dedicated &lt;code>getByRole()&lt;/code> locator method, which is the best way to locate elements using ARIA Roles. Compared with traditional CSS or XPath selectors, role-based location is more stable and semantically explicit.&lt;/p>
&lt;p>&lt;strong>Basic syntax&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;提交&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">click&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Common role location examples&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Locate the button named &amp;#34;Search&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;搜索&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">click&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Locate the checkbox and check it
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;checkbox&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;同意条款&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">check&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Locate the text input and fill in content
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;textbox&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;用户名&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">fill&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;testuser&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Locate the dropdown and select an option
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;combobox&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;国家&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">selectOption&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;中国&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="32-option-parameters-of-the-role-locator">3.2 Option Parameters of the Role Locator
&lt;/h3>&lt;p>The &lt;code>getByRole()&lt;/code> method supports a variety of option parameters for more precise element location:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;提交&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="c1">// accessible name
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">pressed&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="kc">false&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="c1">// button state (whether pressed)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">expanded&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="kc">true&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="c1">// whether expanded (for menus, etc.)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">disabled&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="kc">false&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="c1">// whether disabled
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">checked&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="kc">false&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="c1">// whether checked (checkbox/radio button)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">selected&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="kc">false&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="c1">// whether selected (tabs, etc.)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">includeHidden&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="kc">false&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="c1">// whether to include hidden elements
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="nx">exact&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="kc">true&lt;/span> &lt;span class="c1">// whether the name matches exactly
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="33-verifying-aria-attributes-and-states">3.3 Verifying ARIA Attributes and States
&lt;/h3>&lt;p>Playwright can not only locate elements but also verify ARIA attributes and states:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Verify whether the button is disabled
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;提交&amp;#39;&lt;/span> &lt;span class="p">})).&lt;/span>&lt;span class="nx">toBeDisabled&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Verify whether the checkbox is checked
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;checkbox&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;记住我&amp;#39;&lt;/span> &lt;span class="p">})).&lt;/span>&lt;span class="nx">toBeChecked&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Verify whether the element is visible
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;alert&amp;#39;&lt;/span>&lt;span class="p">)).&lt;/span>&lt;span class="nx">toBeVisible&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Verify the element&amp;#39;s ARIA attribute value
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">const&lt;/span> &lt;span class="nx">button&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;展开&amp;#39;&lt;/span> &lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">button&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="nx">toHaveAttribute&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;aria-expanded&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;false&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="iv-aria-snapshot-testing-in-playwright">IV. ARIA Snapshot Testing in Playwright
&lt;/h2>&lt;p>Playwright provides a powerful ARIA snapshot feature that can capture and verify the accessibility tree structure of a page.&lt;/p>
&lt;h3 id="41-aria-snapshot-basics">4.1 ARIA Snapshot Basics
&lt;/h3>&lt;p>An ARIA snapshot is a YAML representation of the page&amp;rsquo;s accessibility tree, containing the roles, names, states, and hierarchical relationships of elements:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">- &lt;span class="nt">banner&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="l">heading &amp;#34;欢迎页面&amp;#34; [level=1]&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>- &lt;span class="nt">main&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="l">button &amp;#34;提交&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="l">textbox &amp;#34;用户名&amp;#34; [placeholder=&amp;#34;请输入用户名&amp;#34;]&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="42-snapshot-matching-assertions">4.2 Snapshot Matching Assertions
&lt;/h3>&lt;p>Use &lt;code>toMatchAriaSnapshot()&lt;/code> for snapshot verification:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">locator&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;body&amp;#39;&lt;/span>&lt;span class="p">)).&lt;/span>&lt;span class="nx">toMatchAriaSnapshot&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - heading &amp;#34;欢迎页面&amp;#34; [level=1]
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - button &amp;#34;提交&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="43-partial-matching-and-regular-expressions">4.3 Partial Matching and Regular Expressions
&lt;/h3>&lt;p>Snapshots support flexible partial matching:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;span class="lnt">9
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Match the role only, not the name
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">locator&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;dialog&amp;#39;&lt;/span>&lt;span class="p">)).&lt;/span>&lt;span class="nx">toMatchAriaSnapshot&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - dialog
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Use a regular expression to match dynamic text
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">locator&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;body&amp;#39;&lt;/span>&lt;span class="p">)).&lt;/span>&lt;span class="nx">toMatchAriaSnapshot&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - heading /订单 \d+/
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="44-generating-and-updating-snapshots">4.4 Generating and Updating Snapshots
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Update snapshots using the --update-snapshots flag&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npx playwright &lt;span class="nb">test&lt;/span> --update-snapshots
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Or generate it programmatically:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">const&lt;/span> &lt;span class="nx">snapshot&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">locator&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;#main&amp;#39;&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="nx">ariaSnapshot&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nx">console&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">log&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">snapshot&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="v-best-practices-for-aria-testing">V. Best Practices for ARIA Testing
&lt;/h2>&lt;h3 id="51-principles-for-using-roles">5.1 Principles for Using Roles
&lt;/h3>&lt;ol>
&lt;li>&lt;strong>Prefer native HTML elements&lt;/strong>: e.g., use &lt;code>&amp;lt;button&amp;gt;&lt;/code> instead of &lt;code>&amp;lt;div role=&amp;quot;button&amp;quot;&amp;gt;&lt;/code>&lt;/li>
&lt;li>&lt;strong>Avoid redundant roles&lt;/strong>: e.g., &lt;code>&amp;lt;nav role=&amp;quot;navigation&amp;quot;&amp;gt;&lt;/code> is redundant because &lt;code>&amp;lt;nav&amp;gt;&lt;/code> already implies that role&lt;/li>
&lt;li>&lt;strong>Combine roles and attributes correctly&lt;/strong>: e.g., &lt;code>role=&amp;quot;checkbox&amp;quot;&lt;/code> should be used together with &lt;code>aria-checked&lt;/code>&lt;/li>
&lt;/ol>
&lt;h3 id="52-playwright-testing-recommendations">5.2 Playwright Testing Recommendations
&lt;/h3>&lt;ol>
&lt;li>&lt;strong>Prefer ARIA locators&lt;/strong>: more stable and reliable than CSS/XPath&lt;/li>
&lt;li>&lt;strong>Combine with accessible names&lt;/strong>: use the &lt;code>name&lt;/code> option to improve location accuracy&lt;/li>
&lt;li>&lt;strong>Verify dynamic ARIA states&lt;/strong>: such as &lt;code>aria-expanded&lt;/code>, &lt;code>aria-selected&lt;/code>, etc.&lt;/li>
&lt;li>&lt;strong>Check ARIA snapshots regularly&lt;/strong>: ensure the page structure complies with accessibility standards&lt;/li>
&lt;li>&lt;strong>Test keyboard navigation&lt;/strong>: use &lt;code>page.keyboard&lt;/code> to test accessibility&lt;/li>
&lt;/ol>
&lt;h3 id="53-common-issue-troubleshooting">5.3 Common Issue Troubleshooting
&lt;/h3>&lt;ol>
&lt;li>&lt;strong>Element not visible&lt;/strong>: add &lt;code>includeHidden: true&lt;/code> or check the &lt;code>aria-hidden&lt;/code> attribute&lt;/li>
&lt;li>&lt;strong>Name mismatch&lt;/strong>: use &lt;code>exact: false&lt;/code> or a regular expression&lt;/li>
&lt;li>&lt;strong>Dynamic content&lt;/strong>: use &lt;code>await expect().toHaveAttribute()&lt;/code> to wait for state changes&lt;/li>
&lt;li>&lt;strong>Custom controls&lt;/strong>: ensure appropriate ARIA roles and attributes are added&lt;/li>
&lt;/ol>
&lt;h2 id="vi-aria-in-complex-components">VI. ARIA in Complex Components
&lt;/h2>&lt;h3 id="61-navigation-menu-testing">6.1 Navigation Menu Testing
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Expand the menu
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;菜单&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">click&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Verify the menu items
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;menu&amp;#39;&lt;/span>&lt;span class="p">)).&lt;/span>&lt;span class="nx">toMatchAriaSnapshot&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - menu:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - menuitem &amp;#34;首页&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - menuitem &amp;#34;产品&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - menuitem &amp;#34;关于我们&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Select a menu item
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;menuitem&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;产品&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">click&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="62-tabs-testing">6.2 Tabs Testing
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Verify the tab structure
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">locator&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;.tabs-container&amp;#39;&lt;/span>&lt;span class="p">)).&lt;/span>&lt;span class="nx">toMatchAriaSnapshot&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - tablist:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - tab &amp;#34;基本信息&amp;#34; [selected=true]
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - tab &amp;#34;高级设置&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - tabpanel:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - textbox &amp;#34;用户名&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Switch tabs
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;tab&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;高级设置&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">click&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;tab&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;高级设置&amp;#39;&lt;/span> &lt;span class="p">})).&lt;/span>&lt;span class="nx">toHaveAttribute&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;aria-selected&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;true&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="63-modal-dialog-testing">6.3 Modal Dialog Testing
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Open the dialog
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;删除&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">click&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Verify the dialog
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;dialog&amp;#39;&lt;/span>&lt;span class="p">)).&lt;/span>&lt;span class="nx">toMatchAriaSnapshot&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - dialog &amp;#34;确认删除&amp;#34;:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - heading &amp;#34;确认删除&amp;#34; [level=2]
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - button &amp;#34;取消&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - button &amp;#34;确认&amp;#34; [disabled=false]
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// Operate the dialog
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="kr">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">getByRole&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;确认&amp;#39;&lt;/span> &lt;span class="p">}).&lt;/span>&lt;span class="nx">click&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="vii-conclusion">VII. Conclusion
&lt;/h2>&lt;p>As a test automation engineer, mastering W3C ARIA Roles and applying them effectively in Playwright testing brings multiple benefits:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Improved test stability&lt;/strong>: location based on semantic roles is more reliable than location based on implementation details&lt;/li>
&lt;li>&lt;strong>Enhanced accessibility&lt;/strong>: ensure the application complies with WCAG standards and serves a broader user base&lt;/li>
&lt;li>&lt;strong>Simplified test maintenance&lt;/strong>: when UI styles change, role-based tests usually do not need updating&lt;/li>
&lt;li>&lt;strong>Cross-platform testing support&lt;/strong>: ARIA Roles behave consistently across different browsers and devices&lt;/li>
&lt;/ol>
&lt;p>By combining Playwright&amp;rsquo;s ARIA locators, state verification, and snapshot testing features, you can build a robust, maintainable, and accessibility-conscious automated test suite. As web applications grow increasingly complex, the importance of ARIA Roles in test automation will continue to grow, making them one of the core skills that modern web test engineers must master.&lt;/p>
&lt;hr>
&lt;h2 id="v-implementation-recommendations-and-challenges">V. Implementation Recommendations and Challenges
&lt;/h2>&lt;h3 id="51-adoption-roadmap">5.1 Adoption Roadmap
&lt;/h3>&lt;ol>
&lt;li>
&lt;p>&lt;strong>Foundation phase&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>Gradually introduce the &lt;code>getByRole&lt;/code> locator into existing tests&lt;/li>
&lt;li>Add ARIA snapshot comparisons&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Advanced phase&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>Build a role-driven test case library&lt;/li>
&lt;li>Develop ARIA compliance monitoring&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>AI integration phase&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>Train a dedicated role classification model&lt;/li>
&lt;li>Implement automatic test script generation&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;h3 id="52-solutions-to-common-challenges">5.2 Solutions to Common Challenges
&lt;/h3>&lt;p>&lt;strong>Challenge 1: Dynamic Role Assignment&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Solution: use MutationObserver to listen for role changes
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="k">new&lt;/span> &lt;span class="nx">MutationObserver&lt;/span>&lt;span class="p">((&lt;/span>&lt;span class="nx">mutations&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">=&amp;gt;&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">mutations&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">forEach&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">m&lt;/span> &lt;span class="p">=&amp;gt;&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">m&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">attributeName&lt;/span> &lt;span class="o">===&lt;/span> &lt;span class="s1">&amp;#39;role&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">updateAIElementRegistry&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">m&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">target&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}).&lt;/span>&lt;span class="nx">observe&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nb">document&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">{&lt;/span>&lt;span class="nx">attributes&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="kc">true&lt;/span>&lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Challenge 2: Role Misuse Detection&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Solution: pattern recognition algorithm
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">detect_role_misuse&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">element&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">valid_roles&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">get_valid_roles_for_tag&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">element&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">tag_name&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">current_role&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">element&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">get_attribute&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;role&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">current_role&lt;/span> &lt;span class="ow">not&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">valid_roles&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">suggest_native_element&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">element&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">tag_name&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">current_role&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Challenge 3: Cross-Framework Consistency&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Solution: an intermediate abstraction layer
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">[React/Vue/Angular components]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> → [ARIA adaptation layer]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> → [Standardized role tree]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> → [AI test engine]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;/ul></description></item><item><title>AI Testing, the Inevitable Path for Testing Teams</title><link>https://chengxiaqiucao.github.io/en/post/083-ai%E6%B5%8B%E8%AF%95%E8%B7%AF%E7%BA%BF%E5%9B%BE/</link><pubDate>Sat, 26 Apr 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/083-ai%E6%B5%8B%E8%AF%95%E8%B7%AF%E7%BA%BF%E5%9B%BE/</guid><description>&lt;blockquote>
&lt;p>This article is translated and adapted from the latest post on the well-known testing blog &lt;a class="link" href="https://testguild.com/" target="_blank" rel="noopener"
>https://testguild.com/&lt;/a> and discusses a roadmap for systematically implementing and advancing AI testing within testing teams. It offers considerable reference value, so I am sharing it with you all.&lt;/p>&lt;/blockquote>
&lt;h2 id="ai-test-automation-is-no-longer-optional">AI Test Automation Is No Longer Optional
&lt;/h2>&lt;p>In today&amp;rsquo;s software testing field, artificial intelligence (AI) is no longer merely an option but a significant strategic advantage. AI-driven testing tools can automate everything from test case generation to test execution, enabling your team to focus on delivering higher-quality software releases.&lt;/p>
&lt;p>Tal Barmeir, CEO of Blinq.io, once noted: &amp;ldquo;The role of generative AI is to help us truly solve the problem of a massive backlog of testing demand with very limited coverage—a phenomenon we see across every industry.&amp;rdquo;&lt;/p>
&lt;p>AI-driven testing tools can automate the entire process from test case creation to execution and maintenance, helping testing teams:&lt;/p>
&lt;ul>
&lt;li>Reduce test creation time by up to 80%&lt;/li>
&lt;li>Lower test maintenance costs by 40-60%&lt;/li>
&lt;li>Accelerate time to market through faster release cycles&lt;/li>
&lt;li>Improve test coverage across browsers, devices, and environments&lt;/li>
&lt;li>Free up valuable engineering resources for innovation&lt;/li>
&lt;/ul>
&lt;p>This guide offers a structured approach to implementing AI testing, designed to deliver both immediate benefits and long-term transformation.&lt;/p>
&lt;h2 id="phase-1-days-1-15---define-your-ai-testing-strategy">Phase 1 (Days 1-15) - Define Your AI Testing Strategy
&lt;/h2>&lt;p>Before diving into specific tools, you first need to clarify how you want to apply AI:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Assistive AI&lt;/strong>: Enhances human-led testing processes.&lt;/li>
&lt;li>&lt;strong>Autonomous AI&lt;/strong>: Test automation driven entirely by AI, with human oversight.&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>&amp;ldquo;Most organizations start with assistive AI. But they soon realize its value is limited and try to move to fully AI-led. That shift requires different tools, structures, and mindsets.&amp;rdquo;&lt;/p>&lt;/blockquote>
&lt;p>For decision-making leaders of testing teams, the key strategic decisions include:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Scope of automation&lt;/strong>: Is your team automating existing test cases, or allowing AI to take full charge of creating, executing, and maintaining test scripts?&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Integration requirements&lt;/strong>: How will AI testing integrate with your existing CI/CD pipelines and development workflows?&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Success metrics&lt;/strong>: Which KPIs will be used to measure success (such as test coverage, execution time, defect detection, and so on)?&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Risk assessment&lt;/strong>: Which applications or features are best suited as the initial targets for AI testing implementation?&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Action recommendation&lt;/strong>: Before evaluating tools, be sure to define your AI testing vision, scope, and success criteria.&lt;/p>
&lt;h2 id="phase-2-days-16-30---redefine-qa-roles-and-test-inputs">Phase 2 (Days 16-30) - Redefine QA Roles and Test Inputs
&lt;/h2>&lt;p>AI test automation does not eliminate existing roles; rather, it transforms them.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;strong>Traditional Role&lt;/strong>&lt;/th>
&lt;th>&lt;strong>AI-Augmented Role&lt;/strong>&lt;/th>
&lt;th>&lt;strong>Key Responsibilities&lt;/strong>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Manual Tester&lt;/td>
&lt;td>Prompt Engineer&lt;/td>
&lt;td>Create effective test prompts, review AI-generated tests&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Automation Engineer&lt;/td>
&lt;td>AI Testing Lead&lt;/td>
&lt;td>Oversee the generation, execution, and maintenance of AI tests&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>QA Manager&lt;/td>
&lt;td>AI Testing Strategist&lt;/td>
&lt;td>Define AI testing strategy, measure ROI, optimize processes&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;blockquote>
&lt;p>&amp;ldquo;People often think AI means job losses. That is not the case. What it really does is redeploy testers—manual testers become prompt engineers, and automation engineers become supervisors of AI work.&amp;rdquo;&lt;/p>&lt;/blockquote>
&lt;h3 id="expand-test-input-sources">&lt;strong>Expand Test Input Sources&lt;/strong>
&lt;/h3>&lt;p>AI testing platforms can generate comprehensive test cases from a variety of inputs, including:&lt;/p>
&lt;ul>
&lt;li>Jira tickets and user stories&lt;/li>
&lt;li>Screen recordings of application usage&lt;/li>
&lt;li>Natural language requirements&lt;/li>
&lt;li>API specifications and documentation&lt;/li>
&lt;li>Existing manual test cases&lt;/li>
&lt;/ul>
&lt;p>This flexibility means AI testing does not need to strictly adhere to a BDD framework or a specific test case format, making AI testing accessible to teams at every maturity level.&lt;/p>
&lt;h2 id="phase-3-days-31-45---evaluate-ai-testing-tools">Phase 3 (Days 31-45) - Evaluate AI Testing Tools
&lt;/h2>&lt;p>Choosing the right AI testing tool requires aligning it with your infrastructure, team skills, and long-term vision.&lt;/p>
&lt;h3 id="core-capabilities-of-enterprise-ai-testing-platforms">&lt;strong>Core Capabilities of Enterprise AI Testing Platforms&lt;/strong>
&lt;/h3>&lt;ul>
&lt;li>&lt;strong>Open-source test code generation&lt;/strong>: Generates maintainable code in standard frameworks (such as Playwright, Selenium, and so on).&lt;/li>
&lt;li>&lt;strong>Self-healing capability&lt;/strong>: Automatically adapts to user interface (UI) changes without human intervention.&lt;/li>
&lt;li>&lt;strong>Comprehensive test support&lt;/strong>: Covers functional, visual, performance, and security testing.&lt;/li>
&lt;li>&lt;strong>Enterprise integration&lt;/strong>: Works with your CI/CD pipelines, test management, and defect tracking systems.&lt;/li>
&lt;li>&lt;strong>Cross-platform testing&lt;/strong>: Supports web, mobile, API, and enterprise applications (such as Salesforce, SAP, and so on).&lt;/li>
&lt;li>&lt;strong>Visual testing&lt;/strong>: AI-driven visual comparison and anomaly detection.&lt;/li>
&lt;li>&lt;strong>Flaky test management&lt;/strong>: Automatically identifies and resolves inconsistent tests.&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>&amp;ldquo;Even if you stop using a particular vendor, you still have a code project you can maintain. No black box, no vendor lock-in.&amp;rdquo;&lt;/p>&lt;/blockquote>
&lt;p>&lt;strong>Decision framework&lt;/strong>: Evaluate tools against your specific needs, existing infrastructure, and team capabilities. Give priority to platforms that generate standard, maintainable test code rather than proprietary formats.&lt;/p>
&lt;h2 id="phase-4-days-46-60---train-for-new-ai-augmented-testing-roles">Phase 4 (Days 46-60) - Train for New AI-Augmented Testing Roles
&lt;/h2>&lt;p>Introducing AI into test automation brings new AI capabilities and responsibilities, elevating the role of the QA team.&lt;/p>
&lt;h3 id="key-skills-for-the-ai-testing-era">&lt;strong>Key Skills for the AI Testing Era&lt;/strong>
&lt;/h3>&lt;ul>
&lt;li>&lt;strong>Prompt engineering&lt;/strong>: Creating effective test prompts to generate comprehensive test coverage.&lt;/li>
&lt;li>&lt;strong>AI test review&lt;/strong>: Evaluating and refining AI-generated test scripts.&lt;/li>
&lt;li>&lt;strong>Test maintenance management&lt;/strong>: Overseeing self-healing capabilities and test stability.&lt;/li>
&lt;li>&lt;strong>Test prioritization&lt;/strong>: Determining which tests deliver the highest value in each release.&lt;/li>
&lt;li>&lt;strong>Exploratory testing&lt;/strong>: Concentrating human creativity on edge cases and complex scenarios.&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>&amp;ldquo;The old skills were scripting and debugging. The new skills? Writing prompts, reviewing AI suggestions, and managing code at scale.&amp;rdquo;&lt;/p>&lt;/blockquote>
&lt;h3 id="training-resources-for-the-qa-team">&lt;strong>Training Resources for the QA Team&lt;/strong>:
&lt;/h3>&lt;ul>
&lt;li>Internal workshops on AI testing concepts and prompt engineering.&lt;/li>
&lt;li>Vendor-provided training on specific AI testing platforms.&lt;/li>
&lt;li>Hands-on practice in real application testing scenarios.&lt;/li>
&lt;li>Cross-training between manual and automation testers.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Leadership focus&lt;/strong>: Encourage experimentation and create a learning environment where the team can develop AI testing expertise through real-world application.&lt;/p>
&lt;h2 id="phase-5-days-61-75---pilot-and-expand-ai-testing-coverage">Phase 5 (Days 61-75) - Pilot and Expand AI Testing Coverage
&lt;/h2>&lt;p>Launch a focused pilot project using 10-20 test scenarios to achieve fast, measurable impact and build confidence in AI testing capabilities.&lt;/p>
&lt;h3 id="ideal-pilot-project-characteristics">&lt;strong>Ideal Pilot Project Characteristics&lt;/strong>:
&lt;/h3>&lt;ul>
&lt;li>An application of moderate complexity with a stable UI.&lt;/li>
&lt;li>Existing manual test cases for comparison.&lt;/li>
&lt;li>A regular release cadence to demonstrate CI/CD integration.&lt;/li>
&lt;li>A mix of regression, functional, and visual testing needs.&lt;/li>
&lt;li>Stakeholders who are open to innovation and process change.&lt;/li>
&lt;/ul>
&lt;h3 id="implementation-checklist">&lt;strong>Implementation Checklist&lt;/strong>:
&lt;/h3>&lt;ul>
&lt;li>Select the pilot application and define the test scope.&lt;/li>
&lt;li>Configure the AI testing tool and integrate with CI/CD.&lt;/li>
&lt;li>Create initial test prompts and generate baseline tests.&lt;/li>
&lt;li>Execute tests across multiple environments.&lt;/li>
&lt;li>Measure results against traditional testing methods.&lt;/li>
&lt;li>Document lessons learned and optimization opportunities.&lt;/li>
&lt;/ul>
&lt;p>This phase is ideal for expanding test coverage across browsers, devices, and languages—leveraging the multilingual capabilities of AI models to efficiently test international applications.&lt;/p>
&lt;h2 id="phase-6-days-76-90---measure-kpis-and-optimize">Phase 6 (Days 76-90) - Measure KPIs and Optimize
&lt;/h2>&lt;p>Track key performance indicators (KPIs) to quantify the impact of AI testing implementation and uncover optimization opportunities.&lt;/p>
&lt;h3 id="key-ai-testing-metrics">&lt;strong>Key AI Testing Metrics&lt;/strong>:
&lt;/h3>&lt;ul>
&lt;li>&lt;strong>Release time&lt;/strong>: Reduction in overall test cycle time.&lt;/li>
&lt;li>&lt;strong>Test coverage&lt;/strong>: Increase in functional and platform coverage.&lt;/li>
&lt;li>&lt;strong>Maintenance effort&lt;/strong>: Reduction in test script maintenance time.&lt;/li>
&lt;li>&lt;strong>Defect detection&lt;/strong>: Increase in the defect identification rate.&lt;/li>
&lt;li>&lt;strong>Resource utilization&lt;/strong>: The QA team shifting focus to higher-value activities.&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>&amp;ldquo;Most leaders think AI testing is about cutting costs. But the biggest ROI is actually faster time to market.&amp;rdquo;&lt;/p>&lt;/blockquote>
&lt;h3 id="continuous-improvement-framework">&lt;strong>Continuous Improvement Framework&lt;/strong>:
&lt;/h3>&lt;ul>
&lt;li>Review AI testing performance and accuracy weekly.&lt;/li>
&lt;li>Refine prompts based on test results and missed scenarios.&lt;/li>
&lt;li>Extend AI testing to other applications and test types.&lt;/li>
&lt;li>Document best practices and share them across teams.&lt;/li>
&lt;li>Establish an AI testing center of excellence.&lt;/li>
&lt;/ul>
&lt;p>These insights will support your team in making data-driven decisions about test coverage, release readiness, and quality improvement.&lt;/p>
&lt;h2 id="summary---your-90-day-ai-testing-implementation-roadmap">Summary - Your 90-Day AI Testing Implementation Roadmap
&lt;/h2>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;strong>Phase&lt;/strong>&lt;/th>
&lt;th>&lt;strong>Timeline&lt;/strong>&lt;/th>
&lt;th>&lt;strong>Focus&lt;/strong>&lt;/th>
&lt;th>&lt;strong>Key Deliverables&lt;/strong>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1&lt;/td>
&lt;td>Days 1-15&lt;/td>
&lt;td>Strategy definition&lt;/td>
&lt;td>AI testing vision, implementation approach, success metrics&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2&lt;/td>
&lt;td>Days 16-30&lt;/td>
&lt;td>Role transformation&lt;/td>
&lt;td>Updated team structure, skill requirements, input sources&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>3&lt;/td>
&lt;td>Days 31-45&lt;/td>
&lt;td>Tool selection&lt;/td>
&lt;td>AI testing platform evaluation, selection criteria, proof of concept&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>4&lt;/td>
&lt;td>Days 46-60&lt;/td>
&lt;td>Team training&lt;/td>
&lt;td>Skill development plan, training resources, knowledge sharing&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5&lt;/td>
&lt;td>Days 61-75&lt;/td>
&lt;td>Pilot implementation&lt;/td>
&lt;td>Initial AI test suite, CI/CD integration, baseline metrics&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>6&lt;/td>
&lt;td>Days 76-90&lt;/td>
&lt;td>Measurement and optimization&lt;/td>
&lt;td>Performance analysis, optimization plan, scaling strategy&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="the-future-of-qa---ai-driven-testing-leadership">The Future of QA - AI-Driven Testing Leadership
&lt;/h2>&lt;p>With the right AI testing strategy, your QA organization will not only keep pace with the industry but will lead the transformation toward faster, more reliable software delivery. You are not merely automating tests; you are empowering your team to enhance and streamline the entire testing lifecycle, delivering higher-quality software at unprecedented speed while reducing risk and technical debt. Embrace AI testing now, and you will position your organization at the forefront of quality engineering, creating a sustainable competitive advantage through superior software quality and accelerated innovation.&lt;/p></description></item><item><title>Translated - Eight Major Test Automation Trends for 2025</title><link>https://chengxiaqiucao.github.io/en/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/</link><pubDate>Wed, 09 Apr 2025 23:00:28 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/</guid><description>&lt;p>This article comes from &lt;strong>TestGuild&lt;/strong>&amp;rsquo;s analysis in January of this year&amp;rsquo;s testing development trends. So far, its judgments still appear objective and accurate, so I am sharing the translation with everyone.&lt;/p>
&lt;hr>
&lt;p>As we enter 2025, I believe the following &lt;strong>test automation trends&lt;/strong> will profoundly influence the future of software testing.&lt;/p>
&lt;h3 id="table-of-contents">Table of Contents
&lt;/h3>&lt;ul>
&lt;li>&lt;a class="link" href="#trend1" >1. AI Agent - The New Wave of Testing&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="#trend2" >2. Shift-Right AI - Understanding Users&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="#trend3" >3. QA for Everyone - Human-AI Collaboration&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="#trend4" >4. The Evolving Tester Role - Adapting to the Future&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="#trend5" >5. DevOps and SRE Integration - Continuous Quality&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="#trend6" >6. End-to-End (E2E) Autonomous Quality Platforms&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="#trend7" >7. Playwright - The Preferred Automation Tool&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="#trend8" >8. Must-Know Programming Languages for Testers in 2025&lt;/a>&lt;/li>
&lt;li>&lt;a class="link" href="#summary" >Conclusion - The Path to Test Automation Success in 2025&lt;/a>&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="ai-agent---the-new-wave-of-testing">AI Agent - The New Wave of Testing &lt;a id="trend1">&lt;/a>
&lt;/h2>&lt;p>I believe 2025 will witness the continued expansion of AI-assisted testing.&lt;/p>
&lt;p>Why is that?&lt;/p>
&lt;p>The use of AI in testing is growing exponentially: surveys show that, as of 2024, 72.3% of teams are actively exploring or adopting AI-driven testing workflows, whereas just a few years ago this technology was still in the early-adoption stage. This trend marks the fastest technology adoption curve in the history of our TestGuild test automation survey.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409_hu_8cb6e933e68a792.webp"
width="1024"
height="389"
srcset="https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409_hu_5aba6ba2aa501eec.webp 480w, https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409_hu_8cb6e933e68a792.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="263"
data-flex-basis="631px"
>
&lt;/p>
&lt;p>Building on the multimodal AI of 2024 (which processes multiple data types through specialized algorithms), the emerging trend is agentic AI.&lt;/p>
&lt;p>First, you may ask: what exactly is agentic AI?&lt;/p>
&lt;p>Such systems can operate autonomously, handling tasks that previously required human intervention. They can communicate, maintain long-term state, and make independent decisions based on interactions — essentially acting as a highly efficient team of testing assistants.&lt;/p>
&lt;p>Still not clear? Let us illustrate with an example.&lt;/p>
&lt;h3 id="example-of-an-agentic-ai-test-automation-workflow">Example of an Agentic AI Test Automation Workflow
&lt;/h3>&lt;p>Imagine a real-world scenario: agentic AI autonomously manages the full regression test suite for a large e-commerce platform.&lt;/p>
&lt;p>Rather than relying on pre-set scripts and fixed schedules, this agentic AI system will perform the following operations:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Priority determination&lt;/strong>: analyze recent code changes and feature releases, and rank regression tests according to the risk level of the modifications&lt;/li>
&lt;li>&lt;strong>Test selection and adaptation&lt;/strong>: dynamically select appropriate test cases, filtering a subset from the full suite based on risk assessment&lt;/li>
&lt;li>&lt;strong>Test execution and environment management&lt;/strong>: schedule test execution across multiple environments (browser/OS/device). If a test fails, automatically trigger diagnostic tests to collect detailed information, and even attempt to auto-fix simple issues&lt;/li>
&lt;li>&lt;strong>Result analysis and reporting&lt;/strong>: classify the severity of failures, identify patterns, and suggest fixes based on common error patterns&lt;/li>
&lt;li>&lt;strong>Feedback loop and continuous improvement&lt;/strong>: continuously self-optimize through accumulated experience&lt;/li>
&lt;/ul>
&lt;p>This vision is no fantasy. Survey data shows that teams are not only pursuing task automation but also relying on AI to make autonomous decisions — which is precisely the core of agentic AI:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Decision-making capability&lt;/strong>: AI tools are increasingly trusted to optimize test coverage and maintenance&lt;/li>
&lt;li>&lt;strong>Autonomy&lt;/strong>: interest in AI-driven pipelines and frameworks indicates that teams need solutions that minimize human intervention&lt;/li>
&lt;li>&lt;strong>Performance&lt;/strong>: the focus on AI-powered tools and frameworks signals a shift toward systems that learn and adapt dynamically&lt;/li>
&lt;/ul>
&lt;p>The pace of transformation has exceeded expectations: a webinar poll showed that 56% of teams are in the &amp;ldquo;research phase&amp;rdquo; of AI adoption, while 38% of enterprises see AI as a solution to the shortage of testing talent.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409-1_hu_a45b71a4a0209c.webp"
width="1024"
height="953"
srcset="https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409-1_hu_eb3819713d31a4b4.webp 480w, https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409-1_hu_a45b71a4a0209c.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="107"
data-flex-basis="257px"
>
&lt;/p>
&lt;p>The views of industry giants are consistent with this (the author extends them here to the field of test automation):&lt;/p>
&lt;p>Microsoft CEO Satya Nadella recently mentioned &lt;a class="link" href="https://www.cxtoday.com/data-analytics/microsoft-ceo-ai-agents-will-transform-saas-as-we-know-it/" target="_blank" rel="noopener"
>AI &amp;ldquo;agents&amp;rdquo; will transform SaaS&lt;/a>, achieving breakthroughs by handling complex tasks, learning continuously, and connecting seamlessly across systems. Experiments by Stanford researchers on &lt;a class="link" href="https://www.livescience.com/technology/artificial-intelligence/just-2-hours-is-all-it-takes-for-ai-agents-to-replicate-your-personality-with-85-percent-accuracy" target="_blank" rel="noopener"
>AI agents replicating human behavior&lt;/a> likewise confirm the potential of agentic AI to change the way we test.&lt;/p>
&lt;hr>
&lt;h2 id="shift-right-ai---understanding-users">Shift-Right AI - Understanding Users &lt;a id="trend2">&lt;/a>
&lt;/h2>&lt;p>Understanding real user behavior has become a core element of quality strategy in 2025. By analyzing user interactions in production environments, teams can discover patterns, predict problems, and ensure the software meets user expectations. The integration of AI enables teams to explore new paths for improving quality.&lt;/p>
&lt;p>Survey data shows a marked increase in attention to &lt;strong>predictive models and user behavior analysis&lt;/strong>, with teams focusing on using AI to uncover long-tail cases and refine their understanding of the user journey. &lt;a class="link" href="https://testguild.com/podcast/automation/a509-gojko/" target="_blank" rel="noopener"
>Gojko Adzic&lt;/a> envisions tools integrated directly into platforms, providing experience analytics and predictive models that proactively anticipate problems. This is especially valuable when managing massive volumes of user data (including long-tail cases), where AI plays a key role in identifying data patterns.&lt;/p>
&lt;p>This shift-right approach complements traditional shift-left methodologies by emphasizing quality assurance after deployment. Potential benefits include:&lt;/p>
&lt;ul>
&lt;li>Reduce user-reported defects through &lt;strong>proactive monitoring&lt;/strong>&lt;/li>
&lt;li>Improve feature adoption by &lt;strong>optimizing high-value user flows&lt;/strong>&lt;/li>
&lt;li>Improve test coverage through &lt;strong>data-driven decisions&lt;/strong> based on real usage patterns&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="qa-for-everyone---human-ai-collaboration">QA for Everyone - Human-AI Collaboration &lt;a id="trend3">&lt;/a>
&lt;/h2>&lt;p>With the adoption of agentic AI and end-to-end autonomous quality platforms (described in detail below), software testing will undergo dramatic changes in 2025. Low-code/no-code tools combined with AI allow testing to break through traditional barriers, enabling business analysts, developers, and even stakeholders without a technical background to participate in quality assurance. A webinar poll showed that &lt;strong>74%&lt;/strong> of participants considered themselves AI beginners, highlighting the need for tools that lower the barrier to entry.&lt;/p>
&lt;p>Intuitive low-code solutions reduce the learning curve and accelerate tool adoption by automating complex tasks such as test creation and defect detection. Surveys show that &lt;strong>32.3%&lt;/strong> of teams are actively experimenting with no-code testing solutions.&lt;/p>
&lt;p>At the same time, human oversight remains indispensable. As &lt;a class="link" href="https://testguild.com/podcast/automation/a522-tobias/" target="_blank" rel="noopener"
>Tobias Müller&lt;/a> put it: &amp;ldquo;The point is no longer whether to trust AI, but setting boundaries and trusting the rules you have set.&amp;rdquo; Teams that combine human experience with AI demonstrate better defect detection and faster testing cycles, proving the importance of human-AI collaboration.&lt;/p>
&lt;hr>
&lt;h2 id="the-evolving-tester-role---adapting-to-the-future">The Evolving Tester Role - Adapting to the Future &lt;a id="trend4">&lt;/a>
&lt;/h2>&lt;p>Testers are transforming into hybrid roles that blend traditional skills with AI, DevOps, and automation knowledge. Survey data confirms this shift:&lt;/p>
&lt;ul>
&lt;li>45% of teams emphasize the need for AI skills&lt;/li>
&lt;li>51.8% prioritize DevOps knowledge&lt;/li>
&lt;li>72.3% focus on automation expertise&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="devops-and-sre-integration---continuous-quality">DevOps and SRE Integration - Continuous Quality &lt;a id="trend5">&lt;/a>
&lt;/h2>&lt;p>The integration of testing with DevOps and Site Reliability Engineering (SRE) practices is the most significant test automation trend of 2025. As enterprises place growing emphasis on continuous delivery and operational resilience, testing is evolving into a proactive quality assurance activity that runs throughout the software lifecycle.&lt;/p>
&lt;p>Survey data reveals a significant shift: as of 2024, &lt;strong>51.8%&lt;/strong> of teams had adopted DevOps practices (only 16.9% in 2022). This growth confirms the deep integration of testing with DevOps/SRE workflows to safeguard software quality under high-speed delivery.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409-2_hu_5ccd3d9c8fd47040.webp"
width="1024"
height="391"
srcset="https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409-2_hu_c3a3eafcd12c84d5.webp 480w, https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409-2_hu_5ccd3d9c8fd47040.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="262"
data-flex-basis="629px"
>
&lt;/p>
&lt;p>This integration goes beyond traditional QA, turning it into a continuous activity that improves the entire lifecycle and helping enterprises to:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Accelerate feedback loops&lt;/strong>: embed testing into CI/CD pipelines to detect issues immediately&lt;/li>
&lt;li>&lt;strong>Implement proactive quality assurance&lt;/strong>: integrate performance testing and monitoring into workflows to identify risks early&lt;/li>
&lt;li>&lt;strong>Foster team collaboration&lt;/strong>: shared quality ownership improves collaboration among QA, development, and operations teams&lt;/li>
&lt;/ul>
&lt;p>Survey data clearly supports this trend. From pipeline automation to performance monitoring, teams are adopting continuous quality practices aligned with operational excellence goals. If your organization has not yet integrated testing with DevOps/SRE, 2025 is the perfect time to make the transition.&lt;/p>
&lt;hr>
&lt;h2 id="end-to-end-e2e-autonomous-quality-platforms">End-to-End (E2E) Autonomous Quality Platforms &lt;a id="trend6">&lt;/a>
&lt;/h2>&lt;p>E2E platforms are becoming the core of testing strategy. These platforms integrate testing, usability, performance, accessibility, and security within a unified framework to address a broader range of quality concerns. By using AI to automate the testing lifecycle, teams report significant improvements in defect detection and test coverage.&lt;/p>
&lt;p>Survey data shows significant growth:&lt;/p>
&lt;ul>
&lt;li>Security testing grew from 8.2% in 2021 to 39.5% in 2024&lt;/li>
&lt;li>Performance testing adoption reached 41%&lt;/li>
&lt;li>API testing grew from 13.1% in 2021 to 46.2% in 2024&lt;/li>
&lt;/ul>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409230826_hu_8a6ff6dbdecc0bf0.webp"
width="1024"
height="497"
srcset="https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409230826_hu_20f7a83b64e34d53.webp 480w, https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409230826_hu_8a6ff6dbdecc0bf0.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="205"
data-flex-basis="494px"
>
These metrics reflect the growing reliance of enterprises on comprehensive quality platforms to manage all their testing needs.&lt;/p>
&lt;hr>
&lt;h2 id="playwright---the-preferred-automation-tool">Playwright - The Preferred Automation Tool &lt;a id="trend7">&lt;/a>
&lt;/h2>&lt;p>As I predicted last year, Playwright has become the tool of choice for many testers. According to the analysis in &lt;a class="link" href="https://testguild.com/playwright-cypress-ai/" target="_blank" rel="noopener"
>Playwright Surpasses Cypress (Future Outlook)&lt;/a>, this prediction has been validated.&lt;/p>
&lt;p>What about current progress? Thanks to outstanding versatility, reliability, and performance, Playwright continues to consolidate its leading position in 2025. The TestGuild 2024 survey and community feedback show its remarkable growth.&lt;/p>
&lt;p>Testing tool preferences have undergone a major shift (based on an analysis of 2018-2024 data):&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409-3_hu_4c967a7769593ea2.webp"
width="1024"
height="360"
srcset="https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409-3_hu_79c515b284889cc1.webp 480w, https://chengxiaqiucao.github.io/post/074-%E6%9C%80%E6%96%B0%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%B6%8B%E5%8A%BF2025/Pasted-20250409-3_hu_4c967a7769593ea2.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="284"
data-flex-basis="682px"
>
&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Playwright&lt;/strong>: a 45.1% adoption rate makes it the fastest-growing tool, with advantages including cross-browser support, API testing capability, and efficient workflows&lt;/li>
&lt;li>&lt;strong>Selenium&lt;/strong>: once the market leader, its adoption rate has now dropped to 22.1% as teams pursue more efficient and stable solutions&lt;/li>
&lt;li>&lt;strong>Cypress&lt;/strong>: holding its ground in front-end testing, it maintains a stable user base of 14.4%&lt;/li>
&lt;/ul>
&lt;p>Playwright users commonly report:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Faster test execution&lt;/strong>: accelerating feedback loops and improving the development lifecycle&lt;/li>
&lt;li>&lt;strong>Lower test flakiness&lt;/strong>: producing more stable and reliable test results&lt;/li>
&lt;/ul>
&lt;p>Beyond its initial UI browser automation capabilities, Playwright has evolved to support advanced features such as &lt;strong>API testing&lt;/strong>, making it a comprehensive solution for modern testing needs.&lt;/p>
&lt;hr>
&lt;h2 id="must-know-programming-languages-for-testers-in-2025">Must-Know Programming Languages for Testers in 2025 &lt;a id="trend8">&lt;/a>
&lt;/h2>&lt;p>According to the &lt;a class="link" href="https://www.tiobe.com/tiobe-index/" target="_blank" rel="noopener"
>TIOBE Programming Community Index&lt;/a>, Python has topped the list for two consecutive years. This matches my expectation — thanks to its simplicity, strong library support, and dominance in AI/machine learning, Python remains the preferred language for testers in 2025. Whether you are just starting out in automation or are a seasoned testing expert, Python is the bridge connecting today&amp;rsquo;s challenges with the future possibilities of test automation.&lt;/p>
&lt;hr>
&lt;h2 id="conclusion---the-path-to-test-automation-success-in-2025">Conclusion - The Path to Test Automation Success in 2025 &lt;a id="summary">&lt;/a>
&lt;/h2>&lt;p>2025 will be a pivotal turning point for software testing, offering unprecedented opportunities for those who embrace change. The convergence of AI maturity, team collaboration, and tool evolution marks the dawn of a new era in quality assurance.&lt;/p>
&lt;p>Success requires not only paying attention to trends but also taking action:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Embrace agentic AI&lt;/strong>: explore how autonomous AI agents can optimize workflows and reduce human intervention&lt;/li>
&lt;li>&lt;strong>Adopt shift-right testing practices&lt;/strong>: balance traditional shift-left approaches with post-deployment monitoring to ensure the software meets real user expectations&lt;/li>
&lt;li>&lt;strong>Invest in skills development&lt;/strong>: equip your team with AI, automation, and DevOps knowledge to stay competitive&lt;/li>
&lt;li>&lt;strong>Integrate testing with DevOps/SRE&lt;/strong>: break down silos and embed quality assurance into every stage of delivery&lt;/li>
&lt;li>&lt;strong>Make good use of comprehensive tools&lt;/strong>: from Playwright to Python, choose tools that meet current needs and are future-ready&lt;/li>
&lt;/ul>
&lt;p>These trends signal a fundamental shift in how quality assurance is approached. As the boundaries between testing, development, and operations blur, the role of the modern tester is evolving into a strategic one. To gain a deeper grasp of these transformative trends, join the annual &lt;strong>Automation Guild conference&lt;/strong> and help shape the future of testing together with industry leaders.&lt;/p>
&lt;p>The road to innovation in 2025 is already laid out — are you ready to lead the change?&lt;/p>
&lt;hr></description></item><item><title>Ten Misconceptions That Make Testers Harm Quality</title><link>https://chengxiaqiucao.github.io/en/post/071-%E6%B5%8B%E8%AF%95%E4%BA%BA%E5%91%98%E4%BC%A4%E5%AE%B3%E8%B4%A8%E9%87%8F%E7%9A%84%E5%8D%81%E5%A4%A7%E8%AF%AF%E5%8C%BA/</link><pubDate>Fri, 28 Mar 2025 15:59:08 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/071-%E6%B5%8B%E8%AF%95%E4%BA%BA%E5%91%98%E4%BC%A4%E5%AE%B3%E8%B4%A8%E9%87%8F%E7%9A%84%E5%8D%81%E5%A4%A7%E8%AF%AF%E5%8C%BA/</guid><description>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/071-%E6%B5%8B%E8%AF%95%E4%BA%BA%E5%91%98%E4%BC%A4%E5%AE%B3%E8%B4%A8%E9%87%8F%E7%9A%84%E5%8D%81%E5%A4%A7%E8%AF%AF%E5%8C%BA/%E4%BC%A4%E5%AE%B3%E8%B4%A8%E9%87%8F10%E5%A4%A7%E8%AF%AF%E5%8C%BA_hu_81658b60c7e81318.webp"
width="1024"
height="436"
srcset="https://chengxiaqiucao.github.io/post/071-%E6%B5%8B%E8%AF%95%E4%BA%BA%E5%91%98%E4%BC%A4%E5%AE%B3%E8%B4%A8%E9%87%8F%E7%9A%84%E5%8D%81%E5%A4%A7%E8%AF%AF%E5%8C%BA/%E4%BC%A4%E5%AE%B3%E8%B4%A8%E9%87%8F10%E5%A4%A7%E8%AF%AF%E5%8C%BA_hu_d28036d5872caacc.webp 480w, https://chengxiaqiucao.github.io/post/071-%E6%B5%8B%E8%AF%95%E4%BA%BA%E5%91%98%E4%BC%A4%E5%AE%B3%E8%B4%A8%E9%87%8F%E7%9A%84%E5%8D%81%E5%A4%A7%E8%AF%AF%E5%8C%BA/%E4%BC%A4%E5%AE%B3%E8%B4%A8%E9%87%8F10%E5%A4%A7%E8%AF%AF%E5%8C%BA_hu_81658b60c7e81318.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="234"
data-flex-basis="563px"
>
&lt;/p>
&lt;p>Many companies call the engineers who perform testing QA (quality assurance), but QA and Tester are actually two different roles. Even so, there is no denying that a test engineer&amp;rsquo;s primary responsibility is also oriented toward quality — helping the team improve quality by assessing the state of quality.&lt;/p>
&lt;p>But even so, is a test engineer&amp;rsquo;s work necessarily helpful to quality improvement? In real work, some misconceptions can instead make testers&amp;rsquo; work have a negative impact on quality.&lt;/p>
&lt;p>Here Qiucao has sorted out and summarized ten misconceptions by which testers may harm quality, along with the corresponding correct practices.&lt;/p>
&lt;h2 id="1-testings-job-is-to-find-and-report-bugs-but-not-to-confirm-them">1. Testing&amp;rsquo;s job is to find and report Bugs, but not to confirm them
&lt;/h2>&lt;p>&lt;strong>Misconception: Developers and testers often argue over whether a certain issue should be reported as a Bug. &amp;ldquo;The requirement doesn&amp;rsquo;t ask for it,&amp;rdquo; &amp;ldquo;this issue doesn&amp;rsquo;t affect users,&amp;rdquo; and similar reasons come up all the time. Many testers do stop reporting such issues because of these reasons, and some even check with developers whether they are allowed to file a Bug before reporting it.&lt;/strong>&lt;/p>
&lt;p>This is a misconception that does great harm to quality. The value of testing lies in assessing the state of quality, and the key to assessment is independence. Quality is not about right or wrong, only about good or bad. A behavior not defined in the requirements does not mean it is unwanted; not affecting users does not mean it is a good implementation. Testing stands from the perspective of assessing quality, so pointing out defects or raising suggestions for improvement is part of the job. Developers are responsible for analyzing, confirming, and fixing defects. If developers and testers disagree on the confirmation, the PO, business analysts, or CCB members can arbitrate.&lt;/p>
&lt;p>But for testers, reporting &lt;strong>every&lt;/strong> product behavior that they feel is problematic or of poor quality is a professional obligation. Deliberately or inadvertently hiding or covering up defects is the real harm to product quality.&lt;/p>
&lt;h2 id="2-finding-a-bug-is-only-the-beginning-we-should-also-provide-as-much-context-as-possible-for-fixing-it">2. Finding a Bug is only the beginning; we should also provide as much context as possible for fixing it
&lt;/h2>&lt;p>&lt;strong>Misconception: Some testers think that once they have found a problem and reported it, their work is done, that the subsequent fixing process has nothing to do with them, and that all they need to do is verify it after the fix&lt;/strong>&lt;/p>
&lt;p>Testing is one link in the entire software product development lifecycle, and it ultimately serves the overall quality of the product. The Bug itself, in fact, has no value for the product, because only a Bug that has been resolved helps product quality. From this perspective, although reporting Bugs is a tester&amp;rsquo;s main job, for the product the ultimate goal is to resolve the Bug. So as one part of product development, even though fixing Bugs is not directly the tester&amp;rsquo;s responsibility, we should still provide the necessary support for resolving them.&lt;/p>
&lt;p>This part was discussed in detail in a previous article 【】, which you may refer to if interested.&lt;/p>
&lt;h2 id="3-testing-is-not-just-about-verifying-requirements">3. Testing is not just about verifying requirements
&lt;/h2>&lt;p>&lt;strong>Misconception: Testing only needs to verify that the parts explicitly defined in the requirements are correct; undefined parts need not be tested&lt;/strong>&lt;/p>
&lt;p>This is somewhat related to the first misconception and is the premise of many developer–tester arguments about bugs. In the earlier article 【】 on misconceptions about testing goals, we also mentioned this point: beyond verifying requirements, testing should cover much more exploratory work. Testing is not merely checking.&lt;/p>
&lt;p>Beyond that, here I want to emphasize even more the integrity and systematic nature of the product. Especially in an agile development model, this misconception is easily amplified.&lt;/p>
&lt;p>In agile, the output of an agile iteration is the Increment (product increment), which holds true for development work. But testing work is oriented toward the entire product system and cannot cover only the increment. Requirements are incremental too, so of course testing cannot cover only the requirements of the increment. This is why regression testing is a category that must be included in testing, and it is also the fundamental reason test automation is receiving more and more attention. (For analysis and introductions related to agile, see the earlier agile series.)&lt;/p>
&lt;h2 id="4-testing-is-endless-use-good-steel-on-the-blades-edge">4. Testing is endless; use good steel on the blade&amp;rsquo;s edge
&lt;/h2>&lt;p>&lt;strong>Misconception: To find more Bugs, explore and diverge as much as possible, and exploit the clustering effect of Bugs to discover as many Bugs as possible&lt;/strong>&lt;/p>
&lt;p>Still in the article 【】, we also clarified that the goal of testing is not to find more Bugs either. Moreover, testing is in fact endless; the ultimate purpose of testing is to provide a reliable, complete assessment of the quality state of the whole product or system. And whether this quality state is objective and accurate is not necessarily positively correlated with the number of Bugs.&lt;/p>
&lt;p>While finding as many Bugs as possible, testers also need to recognize that we are systematically assessing quality, yet testing can never be exhaustive. Therefore we must allocate our limited time scientifically, giving priority to high-priority parts — new features, code changes, and high-risk modules are all parts that should be tested first and given key assurance.&lt;/p>
&lt;p>&lt;code>Precision Testing&lt;/code> and &lt;code>Risk-Based Testing (RBT)&lt;/code> are practices under this way of thinking that put our testing resources and time first into the high-value parts.&lt;/p>
&lt;h2 id="5-testing-work-does-not-begin-only-at-the-test-submission-stage-it-starts-as-early-as-product-requirement-discussions">5. Testing work does not begin only at the test-submission stage; it starts as early as product requirement discussions
&lt;/h2>&lt;p>&lt;strong>Misconception: Testing should formally begin only after the product is submitted for testing, and Bugs should also be reported only after submission&lt;/strong>&lt;/p>
&lt;p>Today, the above misconception is of course incorrect, because both &lt;code>shift-left testing&lt;/code> and various testing theories emphasize the importance of early testing involvement.&lt;/p>
&lt;p>But theory is theory; in actual practice, testing usually still really begins only after submission for testing.&lt;/p>
&lt;p>On one hand, in the early stage of a product, testing has a low presence and low participation and is easily overlooked;&lt;/p>
&lt;p>on the other hand, many testing teams are assessed heavily on the number of Bugs, which further erodes the motivation for early testing involvement and makes testers less willing to help the team expose product problems early.&lt;/p>
&lt;p>But from the perspective of product delivery, the later the stage, the higher the cost of fixing a problem. So from a product management standpoint, we should abandon the orientation of assessing by Bug count and guide active early participation by testing. Testing can bring its sensitivity to problems into play, identifying and considering many exceptional scenarios starting from requirement discussions, and helping the team avoid them in advance.&lt;/p>
&lt;h2 id="6-in-design-and-architecture-discussions-testing-should-not-be-invisible">6. In design and architecture discussions, testing should not be invisible
&lt;/h2>&lt;p>&lt;strong>Misconception: Architecture and system design, as well as detailed design, are the development team&amp;rsquo;s tasks; testers need not understand or participate in the discussions and can simply wait until product development is complete and then test against the requirements&lt;/strong>&lt;/p>
&lt;p>Similar to the previous point, &lt;code>shift-left testing&lt;/code> does not merely mean that testers understand requirements better; it also requires testers to participate in design and even coding stages.&lt;/p>
&lt;p>We must return to the goal of testing: to assess the quality state of the product as accurately as possible. And quality is necessarily closely tied to the concrete implementation of the product; the more clearly we understand the implementation details, the more targeted our testing can be, including helping the team avoid quality problems in advance during the design and coding stages.&lt;/p>
&lt;p>Conversely, if design and code are a complete black box, it is very likely that some key test scenarios will be missed and problems will leak through.&lt;/p>
&lt;ul>
&lt;li>Without understanding how load balancing is implemented in a cloud application, verifying only on a single node makes it impossible to catch problems caused by load-balancing failures&lt;/li>
&lt;li>Without understanding the system&amp;rsquo;s caching implementation, it is hard to purposefully construct cache-hit scenarios&lt;/li>
&lt;li>Without understanding the responsive layout implementation of the UI, it is hard to efficiently carry out compatibility testing&lt;/li>
&lt;li>Without understanding the interface&amp;rsquo;s validation mechanism, it is hard to construct effective API test data&lt;/li>
&lt;/ul>
&lt;p>All of the above show that testing should not stay outside the design stage and treat product design as outside the scope of testing, thereby ignoring participation in this stage.&lt;/p>
&lt;h2 id="7-an-independent-test-environment-is-a-prerequisite-for-adequate-testing">7. An independent test environment is a prerequisite for adequate testing
&lt;/h2>&lt;p>&lt;strong>Misconception: Test execution only needs to focus on the product itself; testing can be done on an integration environment or even a development environment without affecting test results&lt;/strong>&lt;/p>
&lt;p>It is true that the object of testing is the product itself. But the test environment is actually a key constraint on whether the product can be tested comprehensively and efficiently.&lt;/p>
&lt;p>In software testing and exploration, using the product usually involves the superposition of many different operations and interactions. And when discovering product problems, an important prerequisite for judging the problem is that the relevant preconditions and associated factors of the product itself are clear and definite. To ensure this, an independent, interference-free test environment is especially necessary. If a development environment is used for testing, developers are simultaneously debugging and making changes on that environment during testing, which not only produces a large number of invalid issues but is also a great waste of resources for testing, problem localization, and the like.&lt;/p>
&lt;p>Beyond that, testing inevitably involves creating various exceptional scenarios, and an independent test environment makes it easier for testers to adjust different test scenarios, such as:&lt;/p>
&lt;ul>
&lt;li>Modifying network configurations to create scenarios such as proxy access, internal and external IPs, and weak networks&lt;/li>
&lt;li>Modifying the system time, triggering scheduled tasks, simulating data for different time periods, and similar scenarios&lt;/li>
&lt;li>Simulating scenarios such as insufficient resources, full disk space, and massive or huge files&lt;/li>
&lt;li>Some limiting factors in the product, enabling Debug mode, different authentication settings, and various configuration changes&lt;/li>
&lt;/ul>
&lt;p>All these tests are built on the foundation of an independent, controllable test environment.&lt;/p>
&lt;h2 id="8-test-automation-code-is-also-a-program-treat-test-code-the-way-you-treat-the-product">8. Test automation code is also a program; treat test code the way you treat the product
&lt;/h2>&lt;p>&lt;strong>Misconception: Writing test automation is simply to replace part of manual test execution; once the automation code is written and can run and cover the relevant cases, that is enough&lt;/strong>&lt;/p>
&lt;p>The purpose of test automation is indeed to replace a great deal of manual testing work and achieve efficiency gains. But implementing test automation is not a one-off deal; it is also a long-term process. Moreover, test automation itself is implemented through program code, and where there is a program there will be bugs, so quality assurance and maintenance of the automation scripts and tools themselves is also an important part of a tester&amp;rsquo;s job.&lt;/p>
&lt;p>It is not the case that writing a runnable automation script means we have &amp;ldquo;done automation.&amp;rdquo; Automation scripts, like software products, should go through a lifecycle of requirements analysis, design, coding, testing, and subsequent maintenance.&lt;/p>
&lt;p>So test automation itself is also a fairly large investment. For the relevant scripts to keep delivering value over the long term and truly achieve the goal of improving execution efficiency, good design and continuous maintenance of the test automation code are indispensable.&lt;/p>
&lt;h2 id="9--cicd-pipelines-are-also-testings-responsibility">9. CI/CD pipelines are also testing&amp;rsquo;s responsibility
&lt;/h2>&lt;p>&lt;strong>Misconception: CI/CD, as infrastructure for many development teams today, is usually built and maintained by dedicated DevOps engineers; as testers, we only need to write the automation scripts for the testing portion&lt;/strong>&lt;/p>
&lt;p>Admittedly, within the entire CI/CD pipeline, the part directly related to testing is mainly test automation. But again: testing, as a member of the whole development process, cannot exist independently of that process. Especially in agile development, the integrity of the team is emphasized even more, and the team as a whole is responsible for the development process.&lt;/p>
&lt;p>Therefore, in the process of establishing, operating, and keeping the CI/CD pipeline flowing, there is no clear notion that testing is only responsible for the test automation stage.&lt;/p>
&lt;p>As professionals with a quality perspective, we can also play a greater role in building the CI/CD pipeline:&lt;/p>
&lt;ul>
&lt;li>Defining quality gates for the flow between stages in the pipeline, reflecting shift-left testing in the CI/CD pipeline&lt;/li>
&lt;li>Controlling and identifying code changes, which is highly significant for precision testing in the testing phase&lt;/li>
&lt;li>Monitoring of development, integration, test, and even online production environments, especially the collection and implementation of many quality-related metrics&lt;/li>
&lt;li>Visualization, including automated test reports and the status presentation of various data tracking&lt;/li>
&lt;/ul>
&lt;h2 id="10-cherish-every-opportunity-to-understand-end-users-usage-scenarios">10. Cherish every opportunity to understand end users&amp;rsquo; usage scenarios
&lt;/h2>&lt;p>&lt;strong>Misconception: As a member of the development team, testing need not proactively engage with end users. Interfacing with users is more the job of the sales, after-sales, and customer service teams&lt;/strong>&lt;/p>
&lt;p>Testing work is oriented toward quality, and the ultimate judge of quality is in fact the end user. So many teams emphasize that testing is the voice of the end user, a role that uses and experiences the product from the user&amp;rsquo;s perspective and discovers problems in advance.&lt;/p>
&lt;p>Therefore, in this sense, testing should actually engage with users more, understanding the different scenarios, demands, and even preferences with which users use the product.&lt;/p>
&lt;p>So, when there is an opportunity to engage with users, testing should be proactive rather than resistant. As testers, there are quite a few such opportunities; make full use of chances to engage with users to enrich our understanding of the industry the product belongs to and apply it to our testing work.&lt;/p>
&lt;ul>
&lt;li>User issue support. When some customer issues fed back to the development team require technical support, testers often need to face customers directly, and this is also a place where we intuitively understand users&amp;rsquo; usage scenarios of the product and the problems they face.&lt;/li>
&lt;li>External testing. Before choosing a product, many users will have acceptance testing for it. These tests are often carried out on the customer&amp;rsquo;s side, but product testers often provide support or perform testing as the product side, which is field testing. This is also a great window for deeply understanding user scenarios&lt;/li>
&lt;li>Customer visits. Some companies arrange visits and interviews with end customers in the early or middle stages of product development, and sometimes invite the development team to participate. Although in most cases roles such as system analysts and architects participate more, testing also takes part in such visits, which is an excellent opportunity to deeply understand product application scenarios at an early stage.&lt;/li>
&lt;li>Industry reports. Besides direct communication with end customers, paying attention to industry reports, news, and trend analyses for the industry the product belongs to is likewise an excellent channel for deeply understanding the industry and users the product serves.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;p>The above is a summary of the ten misconceptions by which testers harm quality; everyone is welcome to discuss and add to them.
In addition, for Qiucao&amp;rsquo;s course on systematically improving testing skills, you can reply with &lt;strong>&amp;ldquo;Outline&amp;rdquo;&lt;/strong> or check the course catalog in the official account menu.&lt;/p></description></item><item><title>Software Testing in the AI Era - Assistant or Adversary?</title><link>https://chengxiaqiucao.github.io/en/post/070-ai%E6%97%B6%E4%BB%A3%E7%9A%84%E6%B5%8B%E8%AF%95/</link><pubDate>Tue, 25 Mar 2025 21:38:36 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/070-ai%E6%97%B6%E4%BB%A3%E7%9A%84%E6%B5%8B%E8%AF%95/</guid><description>&lt;p>In the present era, the AI wave is sweeping in, and &amp;ldquo;the future is already here&amp;rdquo; is no longer an empty slogan. AI-related topics and discussions have become the sure-fire &amp;ldquo;traffic magnet&amp;rdquo; of the tech world; from autonomous driving to intelligent customer service, every industry seems eager to ride this wave of AI hype.&lt;/p>
&lt;p>But as testing professionals, when we face the rapid development of AI, what we care about most is probably this: &lt;strong>What can AI actually do in software testing? Can it really help us improve output and efficiency? Or, as it evolves, will AI completely replace testing roles?&lt;/strong>&lt;/p>
&lt;p>In this article, let us explore this topic.&lt;/p>
&lt;h2 id="the-role-of-ai-in-the-different-stages-of-software-testing">The Role of AI in the Different Stages of Software Testing
&lt;/h2>&lt;p>AI testing, when it comes down to it, is about having AI take on part of, assist with, or enhance the original testing work. In other words, AI itself does not change the underlying laws of the software testing lifecycle within software development.&lt;/p>
&lt;p>Therefore, we can look at what role AI can play from the perspective of the different stages of the software testing lifecycle and the scope of testing responsibilities.&lt;/p>
&lt;h3 id="requirements-analysis-stage">Requirements Analysis Stage
&lt;/h3>&lt;p>At this stage, we can use AI&amp;rsquo;s natural language processing technology to sort out the original requirements documents and produce analysis results including business flowcharts, operation flowcharts, and data flow diagrams.&lt;/p>
&lt;p>At the same time, we can combine more relevant local data — such as historical bug data, test logs, and project data — to identify testing priorities, build risk models, and detect risks. Based on these analysis results, we can then help formulate a more reasonable test plan.&lt;/p>
&lt;h3 id="test-case-design-stage">Test Case Design Stage
&lt;/h3>&lt;p>During the software design and development phase, testers usually complete test design in parallel. At this stage, we can leverage AI to help us generate test cases based on the requirements documents and the results of the requirements analysis phase. With AI, we can produce more and fuller positive and negative cases as well as a variety of boundary conditions to expand coverage.&lt;/p>
&lt;h3 id="test-preparation-stage">Test Preparation Stage
&lt;/h3>&lt;p>At this stage, the main work is setting up and deploying the test environment. We can use AI capabilities combined with a CI platform to achieve intelligent management of test servers and database environments, as well as the dynamic allocation of resources.&lt;/p>
&lt;h3 id="test-execution-stage">Test Execution Stage
&lt;/h3>&lt;p>During the execution stage, we can dynamically adjust the test order based on factors such as various risk assessments, dependencies, and business impact, prioritizing coverage of higher-risk modules so as to expose defects as early as possible.&lt;/p>
&lt;p>In addition, AI can enhance capabilities such as log analysis and image comparison, improving our test execution efficiency and defect detection ability.&lt;/p>
&lt;h3 id="test-reporting-stage">Test Reporting Stage
&lt;/h3>&lt;p>In the closing part of testing, using AI to perform comprehensive analysis of various process data can help us produce multi-dimensional test reports, providing project decision-makers with a structured analysis of testing status.&lt;/p>
&lt;h2 id="how-ai-empowers-software-testing-at-this-stage">How AI Empowers Software Testing at This Stage
&lt;/h2>&lt;p>The current development of AI can already provide more support in many typical testing scenarios. The following outlines some typical scenarios that can be empowered by AI:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Intelligent Data Generation&lt;/strong> - Create diverse datasets covering common scenarios and edge cases&lt;/li>
&lt;li>&lt;strong>Test Automation&lt;/strong> - Automatically adapt to UI changes to keep automation scripts stable&lt;/li>
&lt;li>&lt;strong>Precise Regression Testing&lt;/strong> - Intelligently select related test cases based on code changes&lt;/li>
&lt;li>&lt;strong>Process Cloning&lt;/strong> - Learn testing workflows and then automatically execute similar processes&lt;/li>
&lt;li>&lt;strong>Dynamic Waiting Mechanism&lt;/strong> - Intelligently judge page load status before performing actions&lt;/li>
&lt;li>&lt;strong>Intelligent Log Analysis&lt;/strong> - Analyze and identify potential problem patterns in error logs&lt;/li>
&lt;li>&lt;strong>Load / Performance Testing&lt;/strong> - Simulate real user behavior and diagnose performance bottlenecks&lt;/li>
&lt;li>&lt;strong>Continuous Test Monitoring&lt;/strong> - Monitor application status in real time and alert on anomalies&lt;/li>
&lt;li>&lt;strong>Exploratory Testing Support&lt;/strong> - Provide intelligent suggestions during exploratory testing&lt;/li>
&lt;li>&lt;strong>Predictive Analysis&lt;/strong> - Predict release risks based on historical data&lt;/li>
&lt;/ul>
&lt;h2 id="the-advantages-of-introducing-ai">The Advantages of Introducing AI
&lt;/h2>&lt;p>AI can keep learning, training, and improving continuously, so after introducing AI, we can build advantages across many of the following aspects:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Cost Optimization&lt;/strong> - Reduce labor costs, optimize resource allocation, and speed up time to market&lt;/li>
&lt;li>&lt;strong>Stable and Reliable&lt;/strong> - Ensure standardized test execution and result consistency&lt;/li>
&lt;li>&lt;strong>Early Defect Screening&lt;/strong> - Expose problems early and shorten the fix cycle&lt;/li>
&lt;li>&lt;strong>Fast Feedback&lt;/strong> - Run tests in parallel across multiple environments to shorten the feedback loop&lt;/li>
&lt;li>&lt;strong>High-Quality Cases&lt;/strong> - Automatically generate diverse cases such as unit tests, regression tests, and API tests&lt;/li>
&lt;/ul>
&lt;h2 id="significant-challenges-still-remain-in-applying-ai">Significant Challenges Still Remain in Applying AI
&lt;/h2>&lt;h3 id="artificial-intelligence-or">&lt;strong>Artificial Intelligence or &amp;ldquo;Artificial Stupidity&amp;rdquo;?&lt;/strong>
&lt;/h3>&lt;p>If AI&amp;rsquo;s training data is biased, the results can be so absurd that they make you question reality. If the training outcome of AI is not ideal, then applying AI may not only fail to improve efficiency, but also waste a large amount of extra resources correcting its execution results.&lt;/p>
&lt;h3 id="data-dependency-syndrome">&lt;strong>Data Dependency Syndrome&lt;/strong>
&lt;/h3>&lt;p>AI&amp;rsquo;s high demands for quality training data and various parameter adjustments often impose significant constraints on real-world deployment in specific industries.&lt;/p>
&lt;h3 id="maintenance-costs-are-higher-than-you-think">&lt;strong>Maintenance Costs Are Higher Than You Think&lt;/strong>
&lt;/h3>&lt;p>Beyond the investment in data resources, training models on local datasets also requires a great deal of time and money, including equipment resources, which are a considerable expense. In addition, the current shortage of AI talent makes the labor cost of AI applications much higher.&lt;/p>
&lt;h3 id="experience-and-intuition-are-things-ai-can-never-learn">&lt;strong>Experience and Intuition Are Things AI Can Never Learn&lt;/strong>
&lt;/h3>&lt;p>Veteran testers with rich experience can sniff out hidden defects in a product from all kinds of subtle clues; this &amp;ldquo;mystical,&amp;rdquo; sixth-sense-like ability is bound to be difficult for AI to replicate.&lt;/p>
&lt;h2 id="assistant-or-adversary">Assistant or Adversary?
&lt;/h2>&lt;p>&amp;ldquo;With AI developing like this, are test engineers going to lose their jobs?&amp;rdquo; &lt;strong>There is really no need to panic!&lt;/strong>&lt;/p>
&lt;p>AI is still essentially a tool. Just as test automation replaced some manual checks, it only changes parts of the way we work rather than eliminating the role altogether. Future testers will be more like an &amp;ldquo;AI Trainer + Strategy Commander&amp;rdquo; — what we actually need to do boils down to the following:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Teach AI to understand business logic&lt;/strong> (for example, what a &amp;ldquo;correct order status transition&amp;rdquo; is);&lt;/li>
&lt;li>&lt;strong>Design smarter testing strategies&lt;/strong> (for example, how to balance automation and exploratory testing);&lt;/li>
&lt;li>&lt;strong>Interpret AI&amp;rsquo;s results and make decisions&lt;/strong> (for example, whether a given anomaly is a bug or a false positive).&lt;/li>
&lt;/ul>
&lt;p>AI is like a robotic vacuum: it can help you clean the floor, but when it comes to stubborn stains (complex business scenarios) or changes in furniture layout (requirement changes), you still have to step in yourself.&lt;/p>
&lt;h2 id="conclusion---ai-is-not-the-end-but-a-new-starting-point">Conclusion - AI Is Not the End, but a New Starting Point
&lt;/h2>&lt;p>The application of AI in software testing is still in its infancy. We can see its enormous potential, but it is not yet time to place full trust in it and abandon the original models. As testers, rather than worrying about &amp;ldquo;whether we will be replaced,&amp;rdquo; it is better to actively embrace change: learn some basic machine learning, get to know mainstream AI testing tools, and even take part in training your own models.&lt;/p>
&lt;p>After all, &lt;strong>in the future world of software testing, the most sought-after people will certainly not be &amp;ldquo;those who are best at clicking a mouse,&amp;rdquo; but &amp;ldquo;those who are best at working with AI&amp;rdquo;&lt;/strong>. What do you think?&lt;/p>
&lt;hr>
&lt;p>Some earlier articles also discussed the development of AI. For further reading:&lt;/p>
&lt;p>&lt;a class="link" href="https://mp.weixin.qq.com/s/JkBcOzZpVEVJBtvZjE4vEQ?token=645759914&amp;amp;lang=zh_CN" target="_blank" rel="noopener"
>In the AI Era, Do Programmers Still Have a Future?&lt;/a>&lt;/p>
&lt;p>&lt;a class="link" href="https://mp.weixin.qq.com/s/k9Dj9eRBhehPtbMiIHnn9g" target="_blank" rel="noopener"
>The Testing Profession and Its Future Prospects&lt;/a>&lt;/p></description></item><item><title>DeepSeek Prompt Frameworks Help Teams Improve the Status Quo and Boost Efficiency</title><link>https://chengxiaqiucao.github.io/en/post/069-%E4%BC%98%E5%8C%96ai%E6%8F%90%E7%A4%BA%E6%A1%86%E6%9E%B6%E5%AE%9E%E7%8E%B0%E5%9B%A2%E9%98%9F%E6%8F%90%E5%8D%87/</link><pubDate>Wed, 19 Mar 2025 22:44:42 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/069-%E4%BC%98%E5%8C%96ai%E6%8F%90%E7%A4%BA%E6%A1%86%E6%9E%B6%E5%AE%9E%E7%8E%B0%E5%9B%A2%E9%98%9F%E6%8F%90%E5%8D%87/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/069-%E4%BC%98%E5%8C%96ai%E6%8F%90%E7%A4%BA%E6%A1%86%E6%9E%B6%E5%AE%9E%E7%8E%B0%E5%9B%A2%E9%98%9F%E6%8F%90%E5%8D%87/%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%A1%86%E6%9E%B6.webp" alt="Featured image of post DeepSeek Prompt Frameworks Help Teams Improve the Status Quo and Boost Efficiency" />&lt;p>With the rapid development of AI technology, from ChatGPT to the explosion of DeepSeek, AI can now genuinely play a role in assisting our daily work.&lt;/p>
&lt;p>Beyond specific areas such as assisted programming and copywriting, we can also make full use of AI&amp;rsquo;s powerful logical capabilities and vast foundational data to help us propose practical and feasible improvement plans for some of the difficulties we encounter at work.&lt;/p>
&lt;p>But for AI to give us actionable solutions, the design of the prompt framework and the contextual information provided to AI are extremely critical. A well-designed prompt framework can help us quickly obtain highly valuable references.&lt;/p>
&lt;h2 id="a-case-of-the-predicament-we-face">A Case of the Predicament We Face
&lt;/h2>&lt;p>Here we use a fairly common case of an agile team&amp;rsquo;s quality predicament to illustrate:&lt;/p>
&lt;blockquote>
&lt;p>As a test engineer responsible for quality assurance in an agile team running the Scrum framework, the team also includes an SM, a PO, two Android developers (among whom Xiao Li is responsible for the overall system design of the App), one back-end developer, and one part-time visual designer. The team&amp;rsquo;s product is a companion Android App for an IoT smart bracelet product. However, due to issues such as coordination with the hardware team, frequently changing requirements, untimely visual design, delayed test submissions, and a backlog of bugs, product quality is not optimistic. The App has now gone through multiple iterations, and the planned launch date is drawing ever closer. How can we propose an improvement plan for the current quality predicament?&lt;/p>&lt;/blockquote>
&lt;h3 id="designing-the-prompt-framework">Designing the Prompt Framework
&lt;/h3>&lt;p>For AI to help us produce a feasible improvement plan, we first need to design the prompt framework reasonably, so that the final plan better fits the team&amp;rsquo;s current situation and is actionable.&lt;/p>
&lt;p>The key points of the prompt framework design are then:&lt;/p>
&lt;ul>
&lt;li>A given role, so that AI determines from what perspective to propose the improvement plan&lt;/li>
&lt;li>The current status quo, that is, sufficient background information and context&lt;/li>
&lt;li>What AI should analyze in detail, or what its task should be&lt;/li>
&lt;li>The specific output expected from AI, including format requirements and the elements to be included&lt;/li>
&lt;li>Some relevant constraints, which have an important impact on whether the plan is feasible&lt;/li>
&lt;/ul>
&lt;p>Now, for the predicament above, I want AI to help me provide an overall quality improvement plan for the team that can be discussed at the retrospective meeting. Based on the above thinking, by inputting the prompt framework into DeepSeek, we get the following output:&lt;/p>
&lt;h3 id="quality-improvement-plan-for-the-iteration-retrospective">Quality Improvement Plan (For the Iteration Retrospective)
&lt;/h3>&lt;hr>
&lt;h4 id="1-overall-quality-goals">&lt;strong>1. Overall Quality Goals&lt;/strong>
&lt;/h4>&lt;p>&lt;strong>&amp;ldquo;Within 2 iterations, raise automated test coverage to 40%, shorten defect-fix response time by 50%, compress regression testing time by 30%, and establish a quality defense line linking requirement changes with testing&amp;rdquo;&lt;/strong>&lt;/p>
&lt;hr>
&lt;h4 id="2-specific-improvement-initiatives">&lt;strong>2. Specific Improvement Initiatives&lt;/strong>
&lt;/h4>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Initiative&lt;/th>
&lt;th>Owner&lt;/th>
&lt;th>Execution Plan&lt;/th>
&lt;th>Evaluation Method&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>Requirement Freeze Mechanism&lt;/strong>&lt;br>- Lock core functional requirements 3 days before each iteration&lt;br>- Hardware integration requirements are jointly reviewed by the PO and the hardware team to form interface documents&lt;/td>
&lt;td>PO, hardware team lead&lt;/td>
&lt;td>Sign the requirements baseline document at the iteration planning meeting&lt;br>Share hardware interface documents via Confluence&lt;/td>
&lt;td>Reduce requirement changes by 50%&lt;br>Interface document version change records are traceable&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Automated Test Case Tiering Strategy&lt;/strong>&lt;br>- L0 (core business flows): mandatory full automation&lt;br>- L1 (high-frequency usage scenarios): prioritized for automation&lt;br>- L2 (edge scenarios): manual verification&lt;/td>
&lt;td>Test Engineer&lt;br>(Lead)&lt;br>Android Developer&lt;br>(Support)&lt;/td>
&lt;td>Use Allure to label case tiers&lt;br>Daily builds prioritize running L0 cases&lt;/td>
&lt;td>100% pass rate of L0 cases as the test-submission exit criterion&lt;br>Reduce automation execution time by 40%&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Developer Self-Testing Responsibility&lt;/strong>&lt;br>- Code submitted by developers must include unit tests (coverage ≥60%)&lt;br>- API tests are maintained by back-end engineers in Swagger&lt;/td>
&lt;td>Android Developer&lt;br>Back-end Engineer&lt;/td>
&lt;td>Include unit tests as a code review checklist item&lt;br>Link Postman API cases with the code repository&lt;/td>
&lt;td>Raise the smoke-test pass rate of submitted builds to 80%&lt;br>Reduce the API defect rate by 30%&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Hardware Compatibility Mock Service&lt;/strong>&lt;br>- Develop a simulator based on the hardware protocol&lt;br>- Decouple automated testing from real devices&lt;/td>
&lt;td>Test Engineer&lt;br>(Lead)&lt;br>Hardware team provides protocol documents&lt;/td>
&lt;td>Develop a Bluetooth protocol simulator using Python&lt;br>Automatically start the Mock service during Jenkins builds&lt;/td>
&lt;td>Reduce test blockages caused by hardware dependencies to zero&lt;br>Raise automation stability to 95%&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Defect Severity Management&lt;/strong>&lt;br>- P0 defects: respond within 2 hours&lt;br>- P1 defects: must be fixed in the current iteration&lt;br>- Residual defects require the PO to sign off on the risk&lt;/td>
&lt;td>Test Engineer&lt;br>(Classification)&lt;br>Developer&lt;br>(Fix)&lt;/td>
&lt;td>Configure automated defect workflow rules in Jira&lt;br>Sync the progress of the top 3 defects at the daily stand-up&lt;/td>
&lt;td>Shorten the average defect-fix cycle to 8 hours&lt;br>Reduce the number of backlogged defects by 60%&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h4 id="3-risks-and-responses">&lt;strong>3. Risks and Responses&lt;/strong>
&lt;/h4>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Risk&lt;/th>
&lt;th>Response&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Developers resist unit testing&lt;/td>
&lt;td>- Xiao Li (the system designer) demonstrates writing unit tests&lt;br>- Incorporate test coverage into the DoD completion criteria&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>The hardware protocol changes frequently&lt;/td>
&lt;td>- Require the hardware team to notify of protocol changes 3 days in advance&lt;br>- Design a version compatibility mechanism for the Mock service&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>UE design delays affect UI testing&lt;/td>
&lt;td>- Agree with the UE designer: deliver UI element ID specifications together with the visual drafts&lt;br>- Use a screenshot comparison tool with a 10% pixel-difference tolerance&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h4 id="4-external-support-requirements">&lt;strong>4. External Support Requirements&lt;/strong>
&lt;/h4>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Specific Requirements&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Tools&lt;/td>
&lt;td>- Apply for a BrowserStack mobile cloud testing platform license&lt;br>- Purchase an Xray test case management plugin license&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>People&lt;/td>
&lt;td>- The hardware team designates a protocol liaison&lt;br>- A DevOps engineer optimizes the CI/CD pipeline&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Training&lt;/td>
&lt;td>- Invite a unit testing expert to run a TDD workshop&lt;br>- Internal training on advanced Appium usage&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h4 id="5-effect-evaluation-milestones">&lt;strong>5. Effect Evaluation Milestones&lt;/strong>
&lt;/h4>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Milestone&lt;/th>
&lt;th>Verification Criteria&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Mid-iteration 5&lt;/td>
&lt;td>- L0 automated cases cover all core business flows&lt;br>- Unit test coverage ≥40%&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>End of iteration 5&lt;/td>
&lt;td>- Automation coverage ≥25%&lt;br>- Regression testing time ≤8 hours per run&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>End of iteration 6&lt;/td>
&lt;td>- Automation coverage ≥40%&lt;br>- Zero fatal defects in the production environment&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;p>&lt;strong>Notes on Key Execution Points:&lt;/strong>&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Daily Quality Dashboard&lt;/strong>: Hang the automation execution rate / defect trend chart in the team war room&lt;/li>
&lt;li>&lt;strong>Quality Gate Mechanism&lt;/strong>: Code merge requests must pass L0 cases plus SonarQube checks&lt;/li>
&lt;li>&lt;strong>Shift-Left Testing Practice&lt;/strong>: Test engineers produce a test-point matrix as soon as they participate in requirement reviews&lt;/li>
&lt;/ol>
&lt;p>This plan requires the whole team to sign a quality commitment letter. It is recommended that, at the iteration retrospective, the team use the &amp;ldquo;5 Whys analysis&amp;rdquo; to reach a consensus on improvement regarding the current quality issues.&lt;/p>
&lt;p>As we can see, we have obtained an improvement plan that is highly targeted and quite feasible. Based on the team&amp;rsquo;s current situation, we can actually put it into implementation after some fine-tuning.&lt;/p>
&lt;p>So making good use of AI prompt frameworks can not only help us get assistance on specific tasks, but also provide tremendous support for overall improvement initiatives of this kind.&lt;/p>
&lt;p>Reply with &amp;ldquo;prompt framework&amp;rdquo; to get the complete prompt example shown above. Regarding more practical applications of AI at work, everyone is also welcome to leave comments or join the group to discuss!&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/qrcode_for_gh_e12c318badb4_258%20%281%29.jpg"
loading="lazy"
>
&lt;/p></description></item><item><title>Some Pitfalls in Software Testing - Things We Can Do but Should Not Do</title><link>https://chengxiaqiucao.github.io/en/post/067-%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95%E4%B8%AD%E5%8F%AF%E5%81%9A%E4%BD%86%E4%B8%8D%E5%BA%94%E5%81%9A%E7%9A%84%E4%B8%80%E4%BA%9B%E9%99%B7%E9%98%B1/</link><pubDate>Tue, 18 Mar 2025 16:49:04 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/067-%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95%E4%B8%AD%E5%8F%AF%E5%81%9A%E4%BD%86%E4%B8%8D%E5%BA%94%E5%81%9A%E7%9A%84%E4%B8%80%E4%BA%9B%E9%99%B7%E9%98%B1/</guid><description>&lt;h2 id="8-kinds-of-work-in-software-testing-that-">8 Kinds of Work in Software Testing That &lt;strong>&amp;ldquo;We Can Do, but Should Not Do&amp;rdquo;&lt;/strong>
&lt;/h2>&lt;p>In software testing, we often face a problem - many tasks are indeed things we can accomplish, and doing them may seem perfectly natural, yet in many cases these efforts yield very little. These range from over-automation to frequently running unnecessary regression tests, to name a few.&lt;/p>
&lt;p>As technology evolves, the tools available to testers let us accomplish far more, but that does not mean every choice is a wise one. Some tasks, when done blindly, tend to undermine the things that truly matter - output, efficiency, maintainability, and so on.&lt;/p>
&lt;p>This article lists eight pieces of work in testing that &amp;ldquo;we can do, but should not do&amp;rdquo;. Sometimes, taking a step back is the smarter choice.&lt;/p>
&lt;h3 id="1-automating-all-tests">1. Automating All Tests
&lt;/h3>&lt;p>&lt;strong>You can:&lt;/strong> Modern test automation tools let us automate almost any test case - from every click in the user interface to every API call - all of which can technically be driven through automation.&lt;/p>
&lt;p>&lt;strong>But you shouldn&amp;rsquo;t:&lt;/strong> Just because test automation is feasible does not mean it is the best choice. For example:&lt;/p>
&lt;blockquote>
&lt;p>A product&amp;rsquo;s user interface is highly dynamic, with designers adjusting it every week. If you choose to automate every test, the relevant automated tests risk breaking after each UI change.&lt;/p>&lt;/blockquote>
&lt;p>In this case, &lt;strong>manual testing may be more effective&lt;/strong>.&lt;/p>
&lt;h3 id="2-using-overly-complex-locators-in-automation-scripts">2. Using Overly Complex Locators in Automation Scripts
&lt;/h3>&lt;p>&lt;strong>You can:&lt;/strong> In automation tools such as Selenium and Playwright, XPath and CSS selectors let us pinpoint even the deepest elements on a page.&lt;/p>
&lt;p>&lt;strong>But you shouldn&amp;rsquo;t:&lt;/strong> Overly complex locators tend to make tests fragile. For example:&lt;/p>
&lt;blockquote>
&lt;p>Using a complex XPath to locate a menu often causes multiple tests to fail once the development team refactors the HTML structure, forcing the team to spend a great deal of time on fixes.&lt;/p>&lt;/blockquote>
&lt;p>At this point, other approaches may be more effective for the stability of automated cases, such as &lt;strong>agreeing with the development team to add a &lt;code>test-id&lt;/code> attribute to elements&lt;/strong>.&lt;/p>
&lt;h3 id="3-running-the-full-regression-suite-on-every-commit">3. Running the Full Regression Suite on Every Commit
&lt;/h3>&lt;p>&lt;strong>You can:&lt;/strong> In modern CI/CD pipelines, every code commit can easily trigger a full regression run.&lt;/p>
&lt;p>&lt;strong>But you shouldn&amp;rsquo;t:&lt;/strong> In practice, this is often excessive. Imagine a small code fix triggering the entire regression suite, a process that may take several hours or even longer.&lt;/p>
&lt;p>For teams that have not raised automation coverage to a certain level, running a full regression after each commit is an even worse nightmare. The better approach is still to stay on top of what changed and implement &lt;strong>precise testing&lt;/strong> based on the changes and their impact.&lt;/p>
&lt;h3 id="4-over-mocking-in-api-testing">4. Over-Mocking in API Testing
&lt;/h3>&lt;p>&lt;strong>You can:&lt;/strong> Mocking API responses can greatly speed up testing and remove dependencies on external services.&lt;/p>
&lt;p>&lt;strong>But you shouldn&amp;rsquo;t:&lt;/strong> Over-mocking, however, cuts us off from the real environment. A large number of Mock APIs can indeed improve debugging and verification efficiency, but they depart from what genuine testing requires. &lt;strong>Testing in real scenarios is indispensable&lt;/strong>, just as we cannot anticipate every exception.&lt;/p>
&lt;h3 id="5-writing-extremely-detailed-bug-reports-for-trivial-issues">5. Writing Extremely Detailed Bug Reports for Trivial Issues
&lt;/h3>&lt;p>&lt;strong>You can:&lt;/strong> With the help of assistive testing tools, we can catch many small defects in the UI layer, in prompt messages, and the like, and we can write extremely thorough bug reports following case specifications.&lt;/p>
&lt;p>&lt;strong>But you shouldn&amp;rsquo;t:&lt;/strong> Not every minor issue deserves an exhaustive, blow-by-blow report. The purpose of finding a bug is ultimately to fix the bug, not the bug itself, and the value of bugs also varies in importance. I once analyzed what makes a good bug report in 【】 - the value of a bug report lies in being a channel for communicating with developers; the boilerplate text of the report itself has no value.&lt;/p>
&lt;h3 id="6-using-ai-to-generate-test-cases-without-human-supervision">6. Using AI to Generate Test Cases Without Human Supervision
&lt;/h3>&lt;p>&lt;strong>You can:&lt;/strong> Advances in AI have actually made it possible to use AI tools to rapidly generate large numbers of test cases from requirements documents, covering a wide range of scenarios.&lt;/p>
&lt;p>&lt;strong>But you shouldn&amp;rsquo;t:&lt;/strong> Today&amp;rsquo;s AI, however, especially for a specific business domain, lacks human contextual understanding and the combined information gathered through various internal communications, which can lead to redundant cases or to missing critical test cases.&lt;/p>
&lt;h3 id="7-using-too-many-assertions-in-a-test">7. Using Too Many Assertions in a Test
&lt;/h3>&lt;p>&lt;strong>You can:&lt;/strong> Combining automation tools with AI, we can indeed verify a large number of fields, properties, and UI elements within a single test.&lt;/p>
&lt;p>&lt;strong>But you shouldn&amp;rsquo;t:&lt;/strong> Too many assertions, however, only make a test huge and complex and hard to debug. When some assertions fail, it often takes a great deal of effort to track down the cause.&lt;/p>
&lt;h3 id="8-executing-tests-on-every-possible-device-and-browser-combination">8. Executing Tests on Every Possible Device and Browser Combination
&lt;/h3>&lt;p>&lt;strong>You can:&lt;/strong> For compatibility testing, modern cross-browser and cross-device testing tools let us run tests across many operating systems and devices.&lt;/p>
&lt;p>&lt;strong>But you shouldn&amp;rsquo;t:&lt;/strong> Testing every possible combination is neither necessary nor practical. The focus should be on covering the key scenarios that users actually use. Moreover, developments in engineering such as responsive design have greatly reduced the risk of compatibility issues.&lt;/p>
&lt;h3 id="conclusion">Conclusion
&lt;/h3>&lt;p>In software testing, &amp;ldquo;being able to do it&amp;rdquo; does not always mean it is the best choice. We need to find a balance between technical capability and practical feasibility. By avoiding these &amp;ldquo;because we can&amp;rdquo; pitfalls and building a lean, efficient, and genuinely valuable test suite, we contribute far more meaningfully to product quality assurance.&lt;/p>
&lt;p>Welcome to follow QiuCao for a steady stream of more hands-on technical content on software quality!&lt;/p></description></item><item><title>Can You Still Work in Testing Without Coding Skills</title><link>https://chengxiaqiucao.github.io/en/post/065-%E6%B2%A1%E4%BB%A3%E7%A0%81%E8%83%BD%E5%8A%9B%E8%BF%98%E8%83%BD%E5%90%A6%E4%BB%8E%E4%BA%8B%E6%B5%8B%E8%AF%95%E5%B7%A5%E4%BD%9C/</link><pubDate>Sat, 15 Mar 2025 00:04:55 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/065-%E6%B2%A1%E4%BB%A3%E7%A0%81%E8%83%BD%E5%8A%9B%E8%BF%98%E8%83%BD%E5%90%A6%E4%BB%8E%E4%BA%8B%E6%B5%8B%E8%AF%95%E5%B7%A5%E4%BD%9C/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/065-%E6%B2%A1%E4%BB%A3%E7%A0%81%E8%83%BD%E5%8A%9B%E8%BF%98%E8%83%BD%E5%90%A6%E4%BB%8E%E4%BA%8B%E6%B5%8B%E8%AF%95%E5%B7%A5%E4%BD%9C/Pasted-20250316.webp" alt="Featured image of post Can You Still Work in Testing Without Coding Skills" />&lt;blockquote>
&lt;p>Many people from non-IT backgrounds who want to switch to testing have heard it said that software testing has a low barrier to entry—that you can get into the industry even without knowing how to code. So is that actually the case?&lt;/p>&lt;/blockquote>
&lt;p>The answer should be stated plainly:&lt;/p>
&lt;p>&lt;strong>Without coding skills, you actually can work in software testing—and yet, in practice, you actually cannot.&lt;/strong>&lt;/p>
&lt;h2 id="why-you-actually-can">Why you actually can
&lt;/h2>&lt;p>Software testing is not a discipline built on coding ability, which is why, in principle, you can do it.&lt;/p>
&lt;p>Software testing is the act of exposing quality problems in a product through testing; it is, in essence, a skill of discovering the unknown. What matters more, then, are abilities such as experimentation, exploration, observation, reasoning, questioning, and modeling. Having coding skills, on the other hand, mostly helps you understand how the product is implemented, or lets you use code to extend your testing methods and improve testing efficiency. In this sense, coding ability is a supporting capability—one that assists the testing work, but is by no means the decisive factor in whether that work can be accomplished!&lt;/p>
&lt;p>In his paper &amp;ldquo;Testing and Checking&amp;rdquo;, James Bach elaborated on the relationship between &lt;code>testing&lt;/code> and &lt;code>checking&lt;/code>&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/065-%E6%B2%A1%E4%BB%A3%E7%A0%81%E8%83%BD%E5%8A%9B%E8%BF%98%E8%83%BD%E5%90%A6%E4%BB%8E%E4%BA%8B%E6%B5%8B%E8%AF%95%E5%B7%A5%E4%BD%9C/testing-checking_hu_dd929c89bdafaa47.webp"
width="1024"
height="782"
srcset="https://chengxiaqiucao.github.io/post/065-%E6%B2%A1%E4%BB%A3%E7%A0%81%E8%83%BD%E5%8A%9B%E8%BF%98%E8%83%BD%E5%90%A6%E4%BB%8E%E4%BA%8B%E6%B5%8B%E8%AF%95%E5%B7%A5%E4%BD%9C/testing-checking_hu_49031c7ebfaab54e.webp 480w, https://chengxiaqiucao.github.io/post/065-%E6%B2%A1%E4%BB%A3%E7%A0%81%E8%83%BD%E5%8A%9B%E8%BF%98%E8%83%BD%E5%90%A6%E4%BB%8E%E4%BA%8B%E6%B5%8B%E8%AF%95%E5%B7%A5%E4%BD%9C/testing-checking_hu_dd929c89bdafaa47.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="130"
data-flex-basis="314px"
>
&lt;/p>
&lt;p>&lt;code>testing&lt;/code> is the broader concept, while &lt;code>checking&lt;/code> is only a subset of testing—and checking itself is further divided into manual checking and checking performed with the help of machines (tools).&lt;/p>
&lt;p>What coding ability affects, then, falls mostly within that tool-assisted checking part.&lt;/p>
&lt;p>That is why, in the early days, many testing experts who excelled at the work were not particularly good at coding; more often than not, they were domain experts in the relevant business area, equipped with outstanding testing thinking—that is, the detective-like abilities of observation and reasoning mentioned above.&lt;/p>
&lt;p>So, in truth, lacking coding skills does not prevent you from doing testing work exceptionally well.&lt;/p>
&lt;h2 id="why-you-actually-cannot">Why you actually cannot
&lt;/h2>&lt;p>And yet, we must also say that, without coding skills, in practice you really cannot.&lt;/p>
&lt;p>As we noted above, in the &lt;strong>early days&lt;/strong> there were indeed testing experts who could not code. But times have changed, and the reality today is quite different. As the industry has evolved, the direction of the testing profession has arguably departed from its original track. It is rather lamentable, and worthy of a sigh!&lt;/p>
&lt;p>There are several reasons:&lt;/p>
&lt;h3 id="the-rise-of-development-models-that-emphasize-fast-delivery-such-as-agile">The rise of development models that emphasize fast delivery, such as Agile
&lt;/h3>&lt;p>In Agile development models, there is in fact no longer a dedicated testing role; instead, the emphasis is on team members being versatile generalists who can take on a range of development tasks with one specialty and many skills—including both development and testing. As a member of the team, a tester naturally cannot do testing alone; when necessary, they must also be able to pick up development work, at least including tasks originally in the developer&amp;rsquo;s domain such as unit testing and integration testing. Coding ability is, of course, the hard requirement for meeting this condition.&lt;/p>
&lt;h3 id="the-mandatory-requirement-for-test-automation-skills">The mandatory requirement for test automation skills
&lt;/h3>&lt;p>Also driven by the needs of development models such as Agile and continuous integration, test automation has become an indispensable part of the process. And as the foundational capability for test automation, coding ability is naturally a necessity.&lt;/p>
&lt;p>&lt;em>But it must be pointed out here that something like test automation—aimed at &amp;ldquo;quickly completing testing&amp;rdquo;—is, according to the relationship between testing and checking shown in the figure above, not really &amp;ldquo;testing&amp;rdquo; at all; it is much more &amp;ldquo;checking&amp;rdquo;. A single-minded emphasis on coding ability is, in a sense, actually a weakening of the requirements of testing work—that is, it increasingly demands only &amp;ldquo;checking&amp;rdquo; rather than &amp;ldquo;testing&amp;rdquo;.&lt;/em>&lt;/p>
&lt;h3 id="the-talent-market-is-oversupplied">The talent market is oversupplied
&lt;/h3>&lt;p>Finally, there is the industry environment. In the early days of the internet boom, the talent gap was large, and a great deal of &amp;ldquo;verification&amp;rdquo; work was done manually by junior staff or complete beginners with zero foundation who did not need coding skills; manual &amp;ldquo;checking&amp;rdquo; accounted for a larger share.&lt;/p>
&lt;p>But when the industry turns downward, companies cut costs, leading to an oversupplied talent market. The entry barrier naturally rises, job requirements climb accordingly, and expectations for tool-based &amp;ldquo;verification&amp;rdquo; grow higher—so coding ability, test automation, tool development, and the like have all but become must-have skills.&lt;/p>
&lt;p>Layered on top of that is the current prevalence of development models such as Agile and the resulting demand for test automation. It is fair to say that, without coding skills, in today&amp;rsquo;s environment it has become very hard to argue that one can still work in testing—there is simply no way in.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>So, under present conditions, when it comes to testing work, lacking coding skills does not mean you cannot accomplish the work—but without coding ability it has become very difficult to get on board.&lt;/p>
&lt;p>Therefore, as individuals swept along by the tide of the times, what we can do is not to swim against the current, but to steadily build personal capabilities that move with the trend.
But we must still understand what the core requirements of this work truly are—accumulate steadily and then burst forth, for gold only appears after all the sand is washed away!&lt;/p></description></item><item><title>Mastering Regular Expressions and Leaving the Beginner Stage Behind</title><link>https://chengxiaqiucao.github.io/en/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/</link><pubDate>Sun, 09 Mar 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250310.webp" alt="Featured image of post Mastering Regular Expressions and Leaving the Beginner Stage Behind" />&lt;h1 id="preface">Preface
&lt;/h1>&lt;p>&lt;strong>Regular Expression&lt;/strong> is a powerful language for describing text patterns. It uses concise combinations of symbols to describe complex string-matching rules. It is widely used in data validation, text extraction, log analysis, and other fields, and plays an important role in our daily work.&lt;/p>
&lt;p>In the software industry, whether you have mastered regular expressions is often an important marker that separates a rookie from a veteran. In this article, we walk through the application of regular expressions with concrete examples so you can leave the beginner stage behind as soon as possible.&lt;/p>
&lt;h1 id="core-syntax-of-regular-expressions">Core Syntax of Regular Expressions
&lt;/h1>&lt;p>To learn regular expressions, a very intuitive online validation platform is recommended here, &lt;a class="link" href="https://regex101.com" target="_blank" rel="noopener"
>https://regex101.com&lt;/a> , which is very helpful for practicing and mastering regex syntax.&lt;/p>
&lt;h2 id="ordinary-characters-and-special-characters">Ordinary Characters and Special Characters
&lt;/h2>&lt;p>A regular expression is a matching rule. Naturally, it can first match all kinds of ordinary characters, mainly Chinese and English words, letters, and digits. In addition, regular expressions reserve many special characters, such as &lt;code>* ? + . () [] $ ^ \ |&lt;/code>, which represent special matching rules. When we need to treat these special characters as ordinary characters to be matched, we need to use the &lt;code>\&lt;/code> symbol to escape them, so &lt;code>\&lt;/code> is also called the escape character. For example, &lt;code>\?&lt;/code> will match a &lt;code>?&lt;/code> character in the target text, and &lt;code>\\&lt;/code> will match a &lt;code>\&lt;/code> character in the target text&lt;/p>
&lt;h2 id="quantifiers">Quantifiers
&lt;/h2>&lt;p>Quantifiers are symbols used to control the number of matches:&lt;/p>
&lt;ul>
&lt;li>&lt;code>*&lt;/code> zero or more times (e.g. &lt;code>a*&lt;/code> can match &amp;ldquo;&amp;rdquo;, &amp;ldquo;a&amp;rdquo;, &amp;ldquo;aa&amp;rdquo;)&lt;/li>
&lt;li>&lt;code>+&lt;/code> one or more times (&lt;code>a+&lt;/code> must have at least one a)&lt;/li>
&lt;li>&lt;code>?&lt;/code> zero or one time (&lt;code>a?&lt;/code> can match &amp;quot;&amp;quot; or a)&lt;/li>
&lt;li>&lt;code>{n}&lt;/code> matches exactly n times (&lt;code>{4}&lt;/code> matches 4 times)&lt;/li>
&lt;li>&lt;code>{m,n}&lt;/code> matches m to n times (inclusive)&lt;/li>
&lt;li>&lt;code>{m,}&lt;/code> matches m or more times&lt;/li>
&lt;li>&lt;code>{,n}&lt;/code> matches zero to n times&lt;/li>
&lt;/ul>
&lt;p>In addition, there are two matching modes in regular expressions&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Greedy mode&lt;/strong>: this is the default mode, which matches the longest possible run of characters that fit the rule in the target text&lt;/li>
&lt;li>&lt;strong>Lazy mode&lt;/strong>: if a &lt;code>?&lt;/code> is added after a quantifier, it marks a lazy match, that is, matching as few characters as possible that fit the rule&lt;/li>
&lt;/ul>
&lt;p>For example:&lt;/p>
&lt;p>&lt;code>浮云长长长长长长长消&lt;/code>&lt;/p>
&lt;p>This couplet contains 7 &lt;code>长&lt;/code> characters. The regular expression &lt;code>长{2,3}&lt;/code>, in the default greedy mode, will match &lt;code>长长长&lt;/code> 2 times, while &lt;code>长{2,3}?&lt;/code> matches as few characters as possible and will match &lt;code>长长&lt;/code> 3 times&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-1_hu_d9de220055923ce2.webp"
width="1024"
height="435"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-1_hu_b70fd7ead1dce298.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-1_hu_d9de220055923ce2.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="235"
data-flex-basis="564px"
>
&lt;/p>
&lt;h2 id="metacharacters">Metacharacters
&lt;/h2>&lt;p>Besides quantifiers, there is another class of metacharacters, the fundamental special symbols reserved to build regular expressions:&lt;/p>
&lt;ul>
&lt;li>&lt;code>\d&lt;/code> matches a digit (equivalent to &lt;code>[0-9]&lt;/code>)&lt;/li>
&lt;li>&lt;code>\D&lt;/code> matches a non-digit&lt;/li>
&lt;li>&lt;code>\w&lt;/code> matches a word character, including letters, digits, and underscore (equivalent to &lt;code>[A-Za-z0-9_]&lt;/code>)&lt;/li>
&lt;li>&lt;code>\W&lt;/code> matches a non-word character&lt;/li>
&lt;li>&lt;code>\s&lt;/code> matches a whitespace character (space/tab/newline)&lt;/li>
&lt;li>&lt;code>\S&lt;/code> matches a non-whitespace character&lt;/li>
&lt;li>&lt;code>.&lt;/code> matches any single character (by default it does not match a newline)&lt;/li>
&lt;li>&lt;code>|&lt;/code> means logical &amp;ldquo;or&amp;rdquo;&lt;/li>
&lt;/ul>
&lt;h2 id="position-anchors">Position Anchors
&lt;/h2>&lt;p>Used to precisely locate the matching position:&lt;/p>
&lt;ul>
&lt;li>&lt;code>\b&lt;/code> matches a word boundary (e.g. &lt;code>\bcat\b&lt;/code> matches a whole word)&lt;/li>
&lt;li>&lt;code>\B&lt;/code> matches a non-word-boundary&lt;/li>
&lt;li>&lt;code>^&lt;/code> matches the start of the target text, and in multiline mode also matches the start of a line&lt;/li>
&lt;li>&lt;code>$&lt;/code> matches the end of the target text, and in multiline mode also matches the end of a line&lt;/li>
&lt;/ul>
&lt;p>For example:
In &lt;code>tester is good at testing&lt;/code>, using &lt;code>^test&lt;/code> will only match the &lt;code>test&lt;/code> at the start of the line, but the &lt;code>test&lt;/code> in &lt;code>testing&lt;/code> will not be matched; and if &lt;code>test\b&lt;/code> is used, it still matches nothing, because in this text &lt;code>test&lt;/code> is never a standalone word and there is no word boundary after &lt;code>test&lt;/code>&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-2_hu_e57c4616e30233f3.webp"
width="1024"
height="363"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-2_hu_5f004e4cece972f8.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-2_hu_e57c4616e30233f3.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="282"
data-flex-basis="677px"
>
&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-3_hu_49c63ac25bf1fcfc.webp"
width="1024"
height="271"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-3_hu_44ffcaeb136692d2.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-3_hu_49c63ac25bf1fcfc.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="378"
data-flex-basis="907px"
>
&lt;/p>
&lt;h2 id="character-classes">Character Classes
&lt;/h2>&lt;p>Character classes are used to batch-match a specific set of characters:&lt;/p>
&lt;ul>
&lt;li>&lt;code>[abc]&lt;/code> matches any one of a/b/c&lt;/li>
&lt;li>&lt;code>[^abc]&lt;/code> matches characters not in the set&lt;/li>
&lt;li>Range notation: &lt;code>[a-z]&lt;/code> (lowercase letters), &lt;code>[A-Z]&lt;/code> (uppercase letters), &lt;code>[0-9]&lt;/code> (digits)&lt;/li>
&lt;/ul>
&lt;p>In the following example, &lt;code>[b-f]&lt;/code> matches only the &lt;code>d,e&lt;/code> in the target string&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-4_hu_f127e51e99b48bb4.webp"
width="1024"
height="528"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-4_hu_a6ac70d559fc7743.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-4_hu_f127e51e99b48bb4.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="193"
data-flex-basis="465px"
>
&lt;/p>
&lt;h2 id="groups">Groups
&lt;/h2>&lt;p>Grouping is an important technique in regular expressions. It groups matching rules so that matched content can be extracted in subsequent text processing. A group is denoted by enclosing a pattern in &lt;code>()&lt;/code> within the expression.&lt;/p>
&lt;p>For example, specify a string&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">this is a &amp;#34;testtest&amp;#34; string to demo regex group!
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="groups-and-their-references">Groups and Their References
&lt;/h3>&lt;p>Groups are numbered starting from 1 by default, that is, when there are multiple groups, they can be back-referenced in order with &lt;code>\1&lt;/code> &lt;code>\2&lt;/code>&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-5_hu_dbc0212b684aa431.webp"
width="1024"
height="270"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-5_hu_cda5a26520e512a8.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-5_hu_dbc0212b684aa431.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="378"
data-flex-basis="909px"
>
&lt;/p>
&lt;p>In this example, we specify two groups with &lt;code>(is)(\s)\1\2&lt;/code>, group 1 matches &amp;ldquo;is&amp;rdquo;, group 2 matches a whitespace character (here a space), and then &lt;code>\1\2&lt;/code> references these two groups respectively; in effect it matches the case where &lt;code>&amp;quot;is&amp;quot;+space&lt;/code> appears twice in a row&lt;/p>
&lt;h3 id="marking-a-group-as-non-capturing">Marking a Group as Non-Capturing
&lt;/h3>&lt;p>When we group, if we do not want a certain group to be referenced later, we can use &lt;code>(?:pattern)&lt;/code> to mark it, specifying that the current group will not be referenced later. This group is then ignored in the default capture numbering and is not assigned a number.&lt;/p>
&lt;p>In the above example, if we specify that the second group is not to be referenced&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">(is)(?:\s)\1\2
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Then the regular expression in the above example actually has a syntax error and cannot complete the match, because the second group is ignored while &lt;code>\2&lt;/code> references it, which causes a pattern error due to its absence&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-6_hu_501bb13664e3ffea.webp"
width="1024"
height="268"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-6_hu_1951e169585810e6.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-6_hu_501bb13664e3ffea.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="382"
data-flex-basis="917px"
>
&lt;/p>
&lt;h3 id="adding-comments-to-groups">Adding Comments to Groups
&lt;/h3>&lt;p>For some complex regular expressions, we can also add comments to a group to explain the regular expression &lt;code>(?#comment)(other group)&lt;/code>&lt;/p>
&lt;h3 id="naming-groups">Naming Groups
&lt;/h3>&lt;p>Besides referencing groups by their default numeric index, you can also name a group: &lt;code>(?P&amp;lt;name&amp;gt;pattern)&lt;/code>.
Then reference it with &lt;code>(?P=&amp;lt;name&amp;gt;)&lt;/code>&lt;/p>
&lt;p>Based on the above, use the following regex as an illustration&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">(?#这是一个嵌套分组示例)(?P&amp;lt;demo&amp;gt;t(?:\w*)t)(?P=demo)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-7_hu_73049f412eb4a574.webp"
width="1024"
height="214"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-7_hu_7cc1914700d6b2ca.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-7_hu_73049f412eb4a574.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="478"
data-flex-basis="1147px"
>
&lt;/p>
&lt;h2 id="assertions">Assertions
&lt;/h2>&lt;p>Assertions are mainly used for judgment, to match the position of characters that fit a pattern. Because they mainly judge positions and do not consume characters, they are generally also called &lt;strong>zero-width assertions&lt;/strong>&lt;/p>
&lt;p>Assertions can be divided into 4 categories, still using the text from the above example&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">this is a &amp;#34;testtest&amp;#34; string to demo regex group!
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="positive-lookahead-assertion">Positive Lookahead Assertion
&lt;/h3>&lt;p>Judges that the characters after the matching position fit the pattern, asserted with &lt;code>(?=pattern)&lt;/code>&lt;/p>
&lt;p>Example:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-8_hu_43f403aebb7d50f7.webp"
width="1024"
height="185"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-8_hu_304dd4909e00dee7.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-8_hu_43f403aebb7d50f7.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="553"
data-flex-basis="1327px"
>
&lt;/p>
&lt;h3 id="negative-lookahead-assertion">Negative Lookahead Assertion
&lt;/h3>&lt;p>Judges that the characters after the matching position do not fit the given pattern, asserted with &lt;code>(?!pattern)&lt;/code>&lt;/p>
&lt;p>Example:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-9_hu_892678b8586aabf9.webp"
width="1024"
height="464"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-9_hu_e086cef63f86c701.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-9_hu_892678b8586aabf9.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="220"
data-flex-basis="529px"
>
&lt;/p>
&lt;h3 id="positive-lookbehind-and-negative-lookbehind-assertions">Positive Lookbehind and Negative Lookbehind Assertions
&lt;/h3>&lt;p>Opposite to lookahead, lookbehind assertions match whether the characters before the expected position fit a pattern, and also come in positive and negative forms. Adding a &lt;code>&amp;lt;&lt;/code> after the &lt;code>?&lt;/code> indicates lookbehind, namely &lt;code>(?&amp;lt;=pattern)&lt;/code> and &lt;code>(?&amp;lt;!pattern)&lt;/code>&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-10_hu_53e21cb84d0ce355.webp"
width="1024"
height="235"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-10_hu_3d12a725c9dbdbc0.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309-10_hu_53e21cb84d0ce355.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="436"
data-flex-basis="1047px"
>
&lt;/p>
&lt;h1 id="matching-modes">Matching Modes
&lt;/h1>&lt;p>Besides the main matching rules of regular expressions above, regular expressions also have some matching modes. They are represented by &lt;code>\&lt;/code> plus some special letters for different modes&lt;/p>
&lt;ul>
&lt;li>&lt;code>\g&lt;/code> indicates global matching, that is, it matches all qualifying substrings in the given text; if not specified, it only matches the first substring that fits the pattern&lt;/li>
&lt;li>&lt;code>\m&lt;/code> multiline mode, mainly specifies whether &lt;code>^ $&lt;/code> match the start and end of a line&lt;/li>
&lt;li>&lt;code>\i&lt;/code> ignore case when matching&lt;/li>
&lt;li>&lt;code>\x&lt;/code> whether to ignore whitespace in our pattern text when matching, useful when writing more complex rules&lt;/li>
&lt;li>&lt;code>\s&lt;/code> specifies that &lt;code>.&lt;/code> includes the newline character when matching characters&lt;/li>
&lt;li>&lt;code>\u&lt;/code> matches unicode characters, such as Chinese&lt;/li>
&lt;li>&lt;code>\a&lt;/code> matches only ascii characters&lt;/li>
&lt;/ul>
&lt;h1 id="practical-cases">Practical Cases
&lt;/h1>&lt;p>For the following text:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">用户注册信息如下：
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">联系电话：+86 138-0013-8000（北京） / 400-800-8888（全国客服）
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">电子邮箱：support@example.com / service@sub.domain.org.cn / user.name+tag+sorting@example.co.uk
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">网站链接：
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">https://www.example.com/page1.html?query=123&amp;amp;sort=desc#section2
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">http://sub.example.co.jp:8080/admin/dashboard
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ftp://ftp.example.org/upload.zip
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">产品序列号：SKU-20240309-001234（生产日期：2024-03-09）
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">INV-2023-Winter-Sale-0456（有效期至：2024-01-31）
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">活动时间：2024年第一季度（2024-01-01 至 2024-03-31）
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">特殊字符测试：!@#$%^&amp;amp;*()_+-=[]{}|;&amp;#39;:&amp;#34;,./&amp;lt;&amp;gt;?`~
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">测试用密码：Password123!@#（正确） / password123（错误） / Passw0rd!（错误）
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">日志条目：ERROR[2024-03-09T15:40:22+08:00] 用户登录失败
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">IP地址记录：
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">192.168.1.1 / 203.0.113.255 / ::1 / IPv6-Test-Address::FFFFF:1234
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;hr>
&lt;h2 id="matching-a-complete-url-including-protocol-domain-port-and-path">Matching a Complete URL (Including Protocol, Domain, Port, and Path)
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">^(https?:\/\/)([\w\-\.]+\.[a-z]{2,6})(:[0-9]{1,5})?(\/\S*)?$
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Matching result:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309_hu_885e96f570005346.webp"
width="1024"
height="649"
srcset="https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309_hu_aace81bd6d926441.webp 480w, https://chengxiaqiucao.github.io/post/058-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/Pasted-20250309_hu_885e96f570005346.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="157"
data-flex-basis="378px"
>
&lt;/p>
&lt;h2 id="extracting-phone-numbers">Extracting Phone Numbers
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">\b(\+?\d{2,3})[-\s]+?(?:\d{3,4}[- ]?)+
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Explanation: first &lt;code>\b&lt;/code> matches a word boundary, a group extracts the country code (2-3 digits, compatible with the &lt;code>+&lt;/code> case), followed by &lt;code>-&lt;/code> or a space, in lazy mode, then matches the case where 3-4 digits and &lt;code>-&lt;/code> appear consecutively multiple times&lt;/p>
&lt;p>&lt;strong>Matching result&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>&lt;code>+86 138-0013-8000&lt;/code>&lt;/li>
&lt;li>&lt;code>400-800-8888&lt;/code>&lt;/li>
&lt;/ul>
&lt;h2 id="validating-email-addresses">Validating Email Addresses
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">[-.\w]+@[-.\w]+\.[-.\w]+\b
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Matching result&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>&lt;code>support@example.com&lt;/code>&lt;/li>
&lt;li>&lt;code>service@sub.domain.org.cn&lt;/code>&lt;/li>
&lt;li>&lt;code>sorting@example.co.uk&lt;/code>&lt;/li>
&lt;/ul>
&lt;h2 id="capturing-product-serial-numbers-including-date-and-unique-code">Capturing Product Serial Numbers (Including Date and Unique Code)
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">SKU-\d{8}-\d{6}|INV-\d{4}[-A-Za-z]+-\d{4}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Matching result&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>&lt;code>SKU-20240309-001234&lt;/code>&lt;/li>
&lt;li>&lt;code>INV-2023-Winter-Sale-0456&lt;/code>&lt;/li>
&lt;/ul>
&lt;h2 id="matching-chinese-characters">Matching Chinese Characters
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">[\u4e00-\u9fa5]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="parsing-the-timestamp-in-a-log-entry">Parsing the Timestamp in a Log Entry
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">ERROR\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2})\]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Group extraction result&lt;/strong>:
&lt;code>2024-03-09T15:40:22+08:00&lt;/code>&lt;/p>
&lt;h2 id="extracting-ip-addresses">Extracting IP Addresses
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">(?:\d{1,3}\.){3}\d{1,3}|(?:(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4})
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Matching result&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>192.168.1.1&lt;/li>
&lt;li>203.0.113.255&lt;/li>
&lt;/ul>
&lt;h1 id="conclusion">Conclusion
&lt;/h1>&lt;p>The above is a summary of regular expressions and a demonstration of some cases. For more on systematically improving your testing skills, follow my course and reply with &lt;code>outline&lt;/code> to get the detailed syllabus.&lt;/p></description></item><item><title>The For Command in Windows Batch Scripts</title><link>https://chengxiaqiucao.github.io/en/post/063-%E6%89%B9%E5%A4%84%E7%90%86%E8%84%9A%E6%9C%AC%E4%B9%8Bfor%E5%91%BD%E4%BB%A4/</link><pubDate>Sat, 01 Mar 2025 15:13:59 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/063-%E6%89%B9%E5%A4%84%E7%90%86%E8%84%9A%E6%9C%AC%E4%B9%8Bfor%E5%91%BD%E4%BB%A4/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/063-%E6%89%B9%E5%A4%84%E7%90%86%E8%84%9A%E6%9C%AC%E4%B9%8Bfor%E5%91%BD%E4%BB%A4/%E6%89%B9%E5%A4%84%E7%90%86For%E5%91%BD%E4%BB%A4_%E5%85%AC%E4%BC%97%E5%8F%B7.webp" alt="Featured image of post The For Command in Windows Batch Scripts" />&lt;h2 id="introduction">Introduction
&lt;/h2>&lt;p>In our daily work, if you use Windows, making good use of batch commands, especially for bulk file and text processing, can greatly boost productivity and get twice the result with half the effort!&lt;/p>
&lt;p>However, many people&amp;rsquo;s use of batch scripts stops at combining several commands to run together, saving the time of repeatedly typing commands and waiting. This is actually just the most basic way to use batch scripts.&lt;/p>
&lt;p>But to unlock the full power of batch scripts, the &lt;code>for&lt;/code> command is truly the core. As a tool that handles both loop processing and text-column processing, nothing rivals it when it comes to improving batch script efficiency!&lt;/p>
&lt;p>Yet the &lt;code>for&lt;/code> command is relatively complex to use, and many people may not have mastered it well. So in this article, we bring you a systematic introduction to this core command in batch scripting.&lt;/p>
&lt;blockquote>
&lt;p>There&amp;rsquo;s also an Easter egg that Qiucao discovered: Microsoft actually has an official, long-standing bug that has never been fixed 😂😂😂&lt;/p>&lt;/blockquote>
&lt;h2 id="introduction-to-the-for-command">Introduction to the For Command
&lt;/h2>&lt;p>Let&amp;rsquo;s now take a detailed look at this heavyweight command in Windows batch scripting.&lt;/p>
&lt;h3 id="basic-syntax">&lt;strong>Basic Syntax&lt;/strong>
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-batch" data-lang="batch">&lt;span class="line">&lt;span class="cl">&lt;span class="k">FOR&lt;/span> %variable &lt;span class="k">IN&lt;/span> &lt;span class="p">(&lt;/span>set&lt;span class="p">)&lt;/span> &lt;span class="k">DO&lt;/span> command [command-parameters]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ul>
&lt;li>&lt;strong>%variable&lt;/strong>: the for-loop variable; use &lt;code>%%&lt;/code> in batch scripts and &lt;code>%&lt;/code> when running directly from the command line&lt;/li>
&lt;li>(&lt;strong>set)&lt;/strong>: can be a file, a directory, a string, or command output..&lt;/li>
&lt;li>&lt;strong>command&lt;/strong>: the command to execute for each iteration.&lt;/li>
&lt;li>&lt;strong>command-parameters&lt;/strong>: control loop behavior (such as &lt;code>/R&lt;/code>, &lt;code>/D&lt;/code>, &lt;code>/L&lt;/code>, &lt;code>/F&lt;/code>, etc.)&lt;/li>
&lt;/ul>
&lt;p>For example, to iterate over a set:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-batch" data-lang="batch">&lt;span class="line">&lt;span class="cl">&lt;span class="p">@&lt;/span>&lt;span class="k">echo&lt;/span> off
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> &lt;span class="se">%%&lt;/span>a &lt;span class="k">in&lt;/span> &lt;span class="p">(&lt;/span>苹果 香蕉 &lt;span class="s2">&amp;#34;西瓜 芒果&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">do&lt;/span> &lt;span class="k">echo&lt;/span> 水果：&lt;span class="se">%%&lt;/span>a
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Output&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">水果：苹果
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">水果：香蕉
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">水果：&amp;#34;西瓜 芒果&amp;#34;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ul>
&lt;li>&lt;strong>Note&lt;/strong>: by default, elements are separated by spaces, and a quoted string is treated as a whole.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="-the-r-option-recursively-traverse-files">** The &lt;code>/R&lt;/code> Option: Recursively Traverse Files**
&lt;/h3>&lt;p>This option is used to recursively traverse files in a directory and its subdirectories.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-batch" data-lang="batch">&lt;span class="line">&lt;span class="cl">&lt;span class="p">@&lt;/span>&lt;span class="k">echo&lt;/span> off
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> /R &lt;span class="s2">&amp;#34;C:\Chengxiaqiucao&amp;#34;&lt;/span> &lt;span class="se">%%&lt;/span>a &lt;span class="k">in&lt;/span> &lt;span class="p">(&lt;/span>*.txt&lt;span class="p">)&lt;/span> &lt;span class="k">do&lt;/span> &lt;span class="k">echo&lt;/span> 找到文件：&lt;span class="se">%%&lt;/span>a
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Features&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>Traverse all &lt;code>.txt&lt;/code> files under &lt;code>C:\Chengxiaqiucao&lt;/code> and its subdirectories.&lt;/li>
&lt;li>&lt;code>%%a&lt;/code> will contain the full file path (e.g. &lt;code>C:\Chengxiaqiucao\test\file.txt&lt;/code>).&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="d">&lt;strong>&lt;code>/D&lt;/code>: Process Directories&lt;/strong>
&lt;/h3>&lt;p>This option traverses directories only (not files).&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-batch" data-lang="batch">&lt;span class="line">&lt;span class="cl">&lt;span class="p">@&lt;/span>&lt;span class="k">echo&lt;/span> off
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> /D &lt;span class="se">%%&lt;/span>a &lt;span class="k">in&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;C:\*&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">do&lt;/span> &lt;span class="k">echo&lt;/span> 目录：&lt;span class="se">%%&lt;/span>a
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Features&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>List all first-level directories under &lt;code>C:\&lt;/code> (such as &lt;code>Program Files&lt;/code>, &lt;code>Users&lt;/code>, etc.).&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h4 id="4">&lt;strong>4. &lt;code>/L&lt;/code>: Generate a Number Sequence&lt;/strong>
&lt;/h4>&lt;p>This option is similar to controlling the number of loop iterations when programming.&lt;/p>
&lt;p>&lt;strong>Syntax&lt;/strong>: &lt;code>for /L %%a in (start, step, end)&lt;/code>&lt;/p>
&lt;p>The following example generates an arithmetic sequence:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-batch" data-lang="batch">&lt;span class="line">&lt;span class="cl">&lt;span class="p">@&lt;/span>&lt;span class="k">echo&lt;/span> off
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> &lt;span class="k">/L&lt;/span> &lt;span class="se">%%&lt;/span>a &lt;span class="k">in&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="mi">1&lt;/span>, &lt;span class="mi">2&lt;/span>, &lt;span class="mi">10&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">do&lt;/span> &lt;span class="k">echo&lt;/span> 当前数字：&lt;span class="se">%%&lt;/span>a
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Output&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">当前数字：1
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">当前数字：3
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">当前数字：5
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">当前数字：7
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">当前数字：9
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;hr>
&lt;h3 id="f">&lt;strong>&lt;code>/F&lt;/code>: Advanced Text Parsing (The Core Option)&lt;/strong>
&lt;/h3>&lt;p>This option can be considered the most core option of the For command; in most cases, it&amp;rsquo;s what lets the For command truly shine.&lt;/p>
&lt;p>It is mainly used to parse text, strings, or command output line by line, and it supports complex rules.&lt;/p>
&lt;h5 id="syntax">&lt;strong>Syntax&lt;/strong>:
&lt;/h5>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-batch" data-lang="batch">&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> &lt;span class="k">/F&lt;/span> [&lt;span class="s2">&amp;#34;选项&amp;#34;&lt;/span>] &lt;span class="se">%%&lt;/span>a &lt;span class="k">in&lt;/span> &lt;span class="p">(&lt;/span>数据源&lt;span class="p">)&lt;/span> &lt;span class="k">do&lt;/span> 命令
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ul>
&lt;li>&lt;strong>Data source&lt;/strong>: a file, a string, or command output (wrapped in backticks &lt;code>`&lt;/code>).&lt;/li>
&lt;li>&lt;strong>Options&lt;/strong>: &lt;code>delims&lt;/code>, &lt;code>tokens&lt;/code>, &lt;code>skip&lt;/code>, &lt;code>eol&lt;/code>, &lt;code>usebackq&lt;/code>, etc.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h4 id="common-options-of">&lt;strong>Common Options of &lt;code>/F&lt;/code>&lt;/strong>
&lt;/h4>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Option&lt;/th>
&lt;th>Purpose&lt;/th>
&lt;th>Example&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>delims=xyz&lt;/code>&lt;/td>
&lt;td>Define delimiters (default space/tab)&lt;/td>
&lt;td>&lt;code>delims=,&lt;/code> split by comma&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>tokens=n&lt;/code>&lt;/td>
&lt;td>Extract the nth column (separate multiple columns with commas, e.g. &lt;code>1,3&lt;/code>)&lt;/td>
&lt;td>&lt;code>tokens=2&lt;/code> extract the second column&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>skip=n&lt;/code>&lt;/td>
&lt;td>Skip the first n lines&lt;/td>
&lt;td>&lt;code>skip=2&lt;/code> skip the first two lines&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>eol=;&lt;/code>&lt;/td>
&lt;td>Define the line comment character (default &lt;code>;&lt;/code>)&lt;/td>
&lt;td>&lt;code>eol=#&lt;/code> ignore lines starting with &lt;code>#&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>usebackq&lt;/code>&lt;/td>
&lt;td>Change how the data source is quoted (see below)&lt;/td>
&lt;td>Handle paths with spaces or command output&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h4 id="the-role-of">&lt;strong>The Role of &lt;code>usebackq&lt;/code>&lt;/strong>
&lt;/h4>&lt;h5 id="easter-egg-here-a-bug-in-the-official-documentation">Easter Egg Here: A Bug in the Official Documentation
&lt;/h5>&lt;p>In the Chinese official Windows help, the description of the &lt;code>-F&lt;/code> option is actually wrong.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/063-%E6%89%B9%E5%A4%84%E7%90%86%E8%84%9A%E6%9C%AC%E4%B9%8Bfor%E5%91%BD%E4%BB%A4/Pasted-20250303_hu_aeab27828869de65.webp"
width="1024"
height="837"
srcset="https://chengxiaqiucao.github.io/post/063-%E6%89%B9%E5%A4%84%E7%90%86%E8%84%9A%E6%9C%AC%E4%B9%8Bfor%E5%91%BD%E4%BB%A4/Pasted-20250303_hu_2fedcf24ce9887cd.webp 480w, https://chengxiaqiucao.github.io/post/063-%E6%89%B9%E5%A4%84%E7%90%86%E8%84%9A%E6%9C%AC%E4%B9%8Bfor%E5%91%BD%E4%BB%A4/Pasted-20250303_hu_aeab27828869de65.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="122"
data-flex-basis="293px"
>
&lt;/p>
&lt;p>As you can see, the description here for using &lt;code>usebackq&lt;/code> is exactly the same as for not using it, and the Chinese translation is very awkward and hard to understand.&lt;/p>
&lt;p>However, by running the &lt;code>chcp 65001&lt;/code> command to switch the command-line code page to UTF-8, the help is then displayed in English.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/063-%E6%89%B9%E5%A4%84%E7%90%86%E8%84%9A%E6%9C%AC%E4%B9%8Bfor%E5%91%BD%E4%BB%A4/Pasted-20250303-1_hu_53dafe2e36f08e22.webp"
width="1024"
height="1180"
srcset="https://chengxiaqiucao.github.io/post/063-%E6%89%B9%E5%A4%84%E7%90%86%E8%84%9A%E6%9C%AC%E4%B9%8Bfor%E5%91%BD%E4%BB%A4/Pasted-20250303-1_hu_f662bbbb5abdc1ac.webp 480w, https://chengxiaqiucao.github.io/post/063-%E6%89%B9%E5%A4%84%E7%90%86%E8%84%9A%E6%9C%AC%E4%B9%8Bfor%E5%91%BD%E4%BB%A4/Pasted-20250303-1_hu_53dafe2e36f08e22.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="86"
data-flex-basis="208px"
>
&lt;/p>
&lt;p>As you can see, this is much clearer. &lt;code>usebackq&lt;/code> solves the problems in the following scenarios:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Handle file paths with spaces&lt;/strong>: quote the filename with double quotes.&lt;/li>
&lt;li>&lt;strong>Execute a command and parse its output&lt;/strong>: quote the system command with backticks &lt;code>`&lt;/code>.&lt;/li>
&lt;li>&lt;strong>Parse a string directly&lt;/strong>: quote the string with single quotes &lt;code>'&lt;/code>.&lt;/li>
&lt;/ol>
&lt;h5 id="case-1">&lt;strong>Case 1&lt;/strong>:
&lt;/h5>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-batch" data-lang="batch">&lt;span class="line">&lt;span class="cl">&lt;span class="p">@&lt;/span>&lt;span class="k">echo&lt;/span> off
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> &lt;span class="k">/F&lt;/span> &lt;span class="s2">&amp;#34;usebackq delims=&amp;#34;&lt;/span> &lt;span class="se">%%&lt;/span>a &lt;span class="k">in&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;C:\My Files\data.txt&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">do&lt;/span> &lt;span class="k">echo&lt;/span> &lt;span class="se">%%&lt;/span>a
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ul>
&lt;li>Without &lt;code>usebackq&lt;/code>, the spaces in the path would cause a parsing error.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h5 id="-case-2">** Case 2**
&lt;/h5>&lt;p>Parse &lt;code>data.csv&lt;/code> (format: &lt;code>name,age,city&lt;/code>), skip the header line, and extract the name and city.&lt;/p>
&lt;p>&lt;strong>Input file &lt;code>data.csv&lt;/code>&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">姓名,年龄,城市
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">张三,25,北京
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">李四,30,上海
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Batch script:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-batch" data-lang="batch">&lt;span class="line">&lt;span class="cl">&lt;span class="p">@&lt;/span>&lt;span class="k">echo&lt;/span> off
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">for&lt;/span> &lt;span class="k">/F&lt;/span> &lt;span class="s2">&amp;#34;usebackq skip=1 delims=, tokens=1,3&amp;#34;&lt;/span> &lt;span class="se">%%&lt;/span>a &lt;span class="k">in&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;data.csv&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">do&lt;/span> &lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">echo&lt;/span> 姓名：&lt;span class="se">%%&lt;/span>a，城市：&lt;span class="se">%%&lt;/span>b
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Output&lt;/strong>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">姓名：张三，城市：北京
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">姓名：李四，城市：上海
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;hr>
&lt;h2 id="application-scenario-summary">&lt;strong>Application Scenario Summary&lt;/strong>
&lt;/h2>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Option&lt;/th>
&lt;th>Applicable Scenario&lt;/th>
&lt;th>Typical Command Example&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>None&lt;/td>
&lt;td>Iterate over a simple list of files or strings&lt;/td>
&lt;td>&lt;code>for %%a in (*.txt) do echo %%a&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>/R&lt;/code>&lt;/td>
&lt;td>Recursively process files under a directory&lt;/td>
&lt;td>&lt;code>for /R %%a in (*.log) do del %%a&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>/D&lt;/code>&lt;/td>
&lt;td>Process directories only&lt;/td>
&lt;td>&lt;code>for /D %%a in (C:\*) do echo %%a&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>/L&lt;/code>&lt;/td>
&lt;td>Generate a number sequence (e.g. a fixed number of loops)&lt;/td>
&lt;td>&lt;code>for /L %%a in (1,1,5) do echo %%a&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>/F&lt;/code>&lt;/td>
&lt;td>Parse text files, command output, or complex strings&lt;/td>
&lt;td>&lt;code>for /F &amp;quot;tokens=2&amp;quot; %%a in (data.txt)&lt;/code>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>So by mastering these options and techniques of the For command, you can fully turn it into a &amp;ldquo;Swiss Army knife&amp;rdquo; for handling files, text, and system tasks in batch scripts.&lt;/p>
&lt;hr></description></item><item><title>A Guide to grep, One of the Linux Text Processing Trio</title><link>https://chengxiaqiucao.github.io/en/post/060-linux%E6%96%87%E6%9C%AC%E5%A4%84%E7%90%86%E4%B8%89%E5%89%91%E5%AE%A2-grep/</link><pubDate>Thu, 20 Feb 2025 14:02:28 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/060-linux%E6%96%87%E6%9C%AC%E5%A4%84%E7%90%86%E4%B8%89%E5%89%91%E5%AE%A2-grep/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/060-linux%E6%96%87%E6%9C%AC%E5%A4%84%E7%90%86%E4%B8%89%E5%89%91%E5%AE%A2-grep/Pasted-20250310.webp" alt="Featured image of post A Guide to grep, One of the Linux Text Processing Trio" />&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/060-linux%E6%96%87%E6%9C%AC%E5%A4%84%E7%90%86%E4%B8%89%E5%89%91%E5%AE%A2-grep/Pasted-20250310_hu_76c8e40a9b25c995.webp"
width="1024"
height="433"
srcset="https://chengxiaqiucao.github.io/post/060-linux%E6%96%87%E6%9C%AC%E5%A4%84%E7%90%86%E4%B8%89%E5%89%91%E5%AE%A2-grep/Pasted-20250310_hu_9f4ed43d9718def7.webp 480w, https://chengxiaqiucao.github.io/post/060-linux%E6%96%87%E6%9C%AC%E5%A4%84%E7%90%86%E4%B8%89%E5%89%91%E5%AE%A2-grep/Pasted-20250310_hu_76c8e40a9b25c995.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="236"
data-flex-basis="567px"
>
&lt;/p>
&lt;h1 id="preface">Preface
&lt;/h1>&lt;p>&lt;code>grep&lt;/code> is one of the Linux trio (&lt;code>grep&lt;/code>, &lt;code>sed&lt;/code>, &lt;code>awk&lt;/code>), used to search for specific text patterns in files. It is not only powerful but also very flexible, capable of handling a wide variety of text-search needs. Below we walk through the detailed usage of the &lt;code>grep&lt;/code> command and its advanced examples.&lt;/p>
&lt;h1 id="basic-usage">Basic Usage
&lt;/h1>&lt;h2 id="basic-search">Basic Search
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> filename
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Used to search the &lt;code>filename&lt;/code> file for lines containing &lt;code>pattern&lt;/code> and print them out.&lt;/p>
&lt;h2 id="ignoring-case">Ignoring Case
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -i &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> filename
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Use the &lt;code>-i&lt;/code> option to ignore case.&lt;/p>
&lt;h2 id="recursive-search">Recursive Search
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -r &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> directory
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Recursively search the contents of files containing &lt;code>pattern&lt;/code> in the &lt;code>directory&lt;/code> and its subdirectories.&lt;/p>
&lt;h2 id="showing-line-numbers">Showing Line Numbers
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -n &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> filename
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Use the &lt;code>-n&lt;/code> option to show the line numbers of matching lines.&lt;/p>
&lt;h2 id="inverted-search-show-non-matching-lines">Inverted Search (Show Non-Matching Lines)
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -v &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> filename
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Use the &lt;code>-v&lt;/code> option to show lines that do not contain &lt;code>pattern&lt;/code>.&lt;/p>
&lt;h2 id="showing-file-names">Showing File Names
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> file1 file2 file3
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>When searching multiple files, the matching file names are shown by default. Use &lt;code>-H&lt;/code> to force showing file names, and use &lt;code>-h&lt;/code> to hide them.&lt;/p>
&lt;h1 id="advanced-usage">Advanced Usage
&lt;/h1>&lt;h2 id="using-regular-expressions">Using Regular Expressions
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -E &lt;span class="s2">&amp;#34;pattern1|pattern2&amp;#34;&lt;/span> filename
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Use the &lt;code>-E&lt;/code> option to support extended regular expressions, where &lt;code>|&lt;/code> means the OR operation.&lt;/p>
&lt;h2 id="counting-matching-lines">Counting Matching Lines
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -c &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> filename
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Use the &lt;code>-c&lt;/code> option to count the number of matching lines.&lt;/p>
&lt;h2 id="showing-only-the-matched-part">Showing Only the Matched Part
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -o &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> filename
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Use the &lt;code>-o&lt;/code> option to show only the matched part instead of the entire line.&lt;/p>
&lt;h2 id="showing-lines-before-and-after">Showing Lines Before and After
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -A &lt;span class="m">3&lt;/span> &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> filename &lt;span class="c1"># Show the matching line and the 3 lines after it&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">grep -B &lt;span class="m">3&lt;/span> &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> filename &lt;span class="c1"># Show the matching line and the 3 lines before it&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">grep -C &lt;span class="m">3&lt;/span> &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> filename &lt;span class="c1"># Show the matching line and 3 lines before and after it&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The &lt;code>-A&lt;/code>, &lt;code>-B&lt;/code>, and &lt;code>-C&lt;/code> options are used to show a specified number of lines after, before, or both before and after the matching line, respectively.&lt;/p>
&lt;h2 id="reading-data-from-standard-input">Reading Data from Standard Input
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;some text&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> grep &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;code>grep&lt;/code> can read data from standard input, which is very useful in pipeline operations.&lt;/p>
&lt;h2 id="searching-with-fixed-strings-improving-performance">Searching with Fixed Strings (Improving Performance)
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -F &lt;span class="s2">&amp;#34;fixed_string&amp;#34;&lt;/span> filename
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Use the &lt;code>-F&lt;/code> option to treat &lt;code>pattern&lt;/code> as a fixed string rather than a regular expression, which can improve search performance.&lt;/p>
&lt;h2 id="excluding-files">Excluding Files
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -r --exclude&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;*.log&amp;#34;&lt;/span> &lt;span class="s2">&amp;#34;pattern&amp;#34;&lt;/span> directory
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Use the &lt;code>--exclude&lt;/code> option to exclude files of a certain type.&lt;/p>
&lt;h2 id="using-perl-compatible-regular-expressions">Using Perl-Compatible Regular Expressions
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -P &lt;span class="s2">&amp;#34;\d+&amp;#34;&lt;/span> filename
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Use the &lt;code>-P&lt;/code> option to enable Perl-compatible regular expressions, where &lt;code>\d+&lt;/code> means one or more digits.&lt;/p>
&lt;h2 id="zero-width-assertions">Zero-Width Assertions
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -P &lt;span class="s1">&amp;#39;(?&amp;lt;=foo)bar&amp;#39;&lt;/span> filename
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Use Perl-compatible regular expressions to support zero-width assertions; for example, &lt;code>(?&amp;lt;=foo)bar&lt;/code> matches a &lt;code>bar&lt;/code> that is preceded by &lt;code>foo&lt;/code>.&lt;/p>
&lt;h1 id="combined-usage-examples">Combined Usage Examples
&lt;/h1>&lt;h2 id="finding-files-of-a-specific-type-in-a-specific-directory-and-searching-their-contents">Finding Files of a Specific Type in a Specific Directory and Searching Their Contents
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -r --include&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;*.py&amp;#34;&lt;/span> &lt;span class="s2">&amp;#34;import&amp;#34;&lt;/span> /path/to/directory
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Recursively search all &lt;code>.py&lt;/code> files in the &lt;code>/path/to/directory&lt;/code> directory for lines containing &lt;code>import&lt;/code>.&lt;/p>
&lt;h2 id="finding-and-showing-matching-lines-with-two-lines-before-and-after">Finding and Showing Matching Lines with Two Lines Before and After
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -C &lt;span class="m">2&lt;/span> &lt;span class="s2">&amp;#34;error&amp;#34;&lt;/span> /var/log/syslog
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Find lines containing &lt;code>error&lt;/code> in the &lt;code>/var/log/syslog&lt;/code> file and show the two lines before and after them.&lt;/p>
&lt;h2 id="counting-the-number-of-files-containing-a-specific-word">Counting the Number of Files Containing a Specific Word
&lt;/h2>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">grep -rl &lt;span class="s2">&amp;#34;word&amp;#34;&lt;/span> /path/to/directory &lt;span class="p">|&lt;/span> wc -l
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Recursively search the &lt;code>/path/to/directory&lt;/code> directory for files containing &lt;code>word&lt;/code>, and count the number of files.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>Through these examples, you can appreciate the power and flexibility of &lt;code>grep&lt;/code>, which also makes it one of the most practical text-processing tools in Linux.&lt;/p></description></item></channel></rss>