In-Depth Analysis of Three AI Test Automation Approaches: Code Scripting, DOM Parsing, and Visual Models

A deep dive into the three AI test automation approaches: code scripting, DOM parsing, and visual models.
This article systematically breaks down the three mainstream test automation approaches in the AI era—AI-generated code scripts, DOM parsing driven, and LVM visual model driven—comparing their principles, strengths, weaknesses, and use cases to help test engineers build a comprehensive understanding of AI automation and boost their career competitiveness.
In an era where AI is rapidly permeating the software testing industry, the way we do test automation has fundamentally changed. Many test engineers face a common confusion: with the rise of AI, a host of new automation methods have emerged—so how many of them have I actually mastered? Which one should I use at work? And how do I differentiate myself from other candidates in interviews?
This article systematically walks through the three mainstream test automation approaches in the AI era: code scripting (AI programming), DOM parsing driven, and visual model (LVM) driven, helping you build a comprehensive understanding of AI test automation.


Industry Background: From "Humans Using Tools" to "AI Using Tools"
Before AI, test automation relied primarily on two approaches: first, using ready-made automation tools (such as Selenium script recording, Postman, JMeter, Apifox, MeterSphere, etc.); second, writing automated test scripts through programming languages. The pain point of the former was that tools often didn't fit specific projects, requiring extensive customization and extension.
The biggest change in the AI era can be summed up in one word—efficiency. The industry's relentless pursuit of efficiency is reshaping every role. One obvious signal is that the users of tools are shifting from testers to AI Agents.
Looking at the major version updates of Postman and Apifox over recent years, you'll find they almost entirely revolve around AI capabilities. In Postman, as long as you can type, you can generate scripts—no more manual coding required.
This signals two key shifts: the user of tools has shifted from humans to AI Agents, and the author of scripts has also shifted from humans to AI Agents. But AI doesn't inherently possess these capabilities—it needs a full set of tools and knowledge to support it. This is precisely the premise for understanding the three approaches.
Approach One: AI Programming to Generate Code Scripts
The first approach is the most familiar to most people—writing code scripts. The difference is that now AI does the coding work, in what's called "AI programming" or "Vibe Coding."
Using Skills to Make AI Output Controllable and Reusable
This introduces a core concept—Skill. A Skill is essentially a set of description files that tell the AI how to accomplish a task. Its physical form is a folder containing a SKILL.md. Place it in the Agent tool's designated directory, and the Agent will automatically load the description information within it when executing commands.
A typical use case: in an empty project, you directly invoke a Skill, and the AI will "create a web automation test project scaffold based on PyTest + Playwright + Allure in the current directory according to the Skill template."
Why use a Skill instead of just letting the AI generate directly? The key is controllability:
- If you let the AI generate the scaffold directly, the results are often inconsistent between two runs;
- Once encapsulated as a Skill, the result generated each time is standardized and controllable.
More importantly, there's a shift in the learning paradigm. The biggest pain point of learning automation in the past was "learn it and forget it"—you had to memorize PyTest syntax, POM object encapsulation, and Allure report configuration. Now, you can encapsulate your learning outcomes into individual Skills:
After learning a framework, have the AI encapsulate the learning outcome into a Skill. When you need it later, just invoke "the Skill I encapsulated six months ago to quickly generate a scaffold for me"—no more piecing things together from the internet and repeatedly tweaking.
These Skills are not just reusable work assets—they're also concrete achievements you can showcase in interviews.
Core Advantages of the Code Scripting Approach
AI can quickly complete the full workflow of scaffold generation, test case writing, POM object encapsulation and successful execution, and Allure test report generation. The biggest characteristic of this approach is: fast execution speed. When the code approach runs multiple test cases and generates reports in just a few seconds, the two AI-driven approaches below may have only completed a single operation.
Approach Two: DOM Parsing Driven with Agent + Skill
As practice deepens, a natural question emerges: since AI can now directly operate the browser, why still write code?
Give the AI natural language commands directly: "Click My Bookshelf → Click a certain novel → Check whether it enters the detail page; if so, output test passed." The AI autonomously completes page clicking, content recognition, and assertion judgment. This is the second approach—autonomous test execution with Agent + AI tools + Skill (natural language driven).
The Underlying Principle of DOM Mode
The key tool here is Playwright CLI. The essence of this Skill is:
A set of documentation + Playwright's official CLI command-line tool
Playwright CLI is a command-line tool developed by Microsoft based on the Playwright framework. Its working principle is as follows:
- The AI calls Playwright CLI commands to obtain a page snapshot (DOM information);
- Playwright numbers all elements on the current page (e.g., homepage numbered 15, login button numbered 116);
- The LLM matches the target element number based on user input;
- It then calls Playwright to execute the corresponding operation.
Essentially, it turns the page "into text." HTML is inherently hypertext, so the AI can know where each element is and how to operate it by reading the DOM information. The AI doesn't actually not need element location—Playwright does the numbering and location work for it.
The Essential Difference from Code Mode
First, there's no need to write code for every operation—operations like clicking, typing, dropdown, and dragging are already encapsulated into CLI commands.
Second, the invocation method is different—code is "prefabricated," with fixed behavior once written; it fails as soon as page elements change. AI-driven approaches, however, can dynamically and flexibly invoke different operations based on page changes—call click when clicking is needed, call swipe when swiping is needed.
Three Major Drawbacks of DOM Mode
This approach has the following limitations:
- Consumes tokens and depends on model capability: Every step requires the LLM to make dynamic judgments; poor model quality may prevent scripts from running successfully.
- Context limitations: When pages are complex or workflows involve multiple pages, it easily triggers the LLM's context bottleneck, causing forgetting and hallucinations (e.g., filling the department ID into the employee ID field).
- Slower execution speed than code scripts.
But its advantage is equally significant—extremely low cost. A tester with a monthly salary of 15,000 RMB averages about 100 RMB/hour; whereas 100 RMB worth of tokens can accomplish a lot in the testing domain. For small-scale, uncomplicated projects, or scenarios like smoke testing and online inspections, AI natural-language-driven approaches offer extremely high cost-effectiveness.
Approach Three: LVM Visual Model Driven
DOM mode has one weak spot: if the page development is non-standard, making elements impossible to locate, or if there are too many similar elements (multiple login/delete buttons) causing misjudgment, or when facing scenarios like games and icons with no clear text or elements, it struggles. This is where the third approach comes in—driven by a Large Vision Model (LVM).
Visual Models: "Seeing" the Page Like a Human
LVM stands for Large Vision Model, and its core processing target is images. Unlike Playwright CLI, which obtains the DOM, the visual model obtains the page image that the human eye can see.
The most intuitive example: telling the AI to "click a novel with a pink cover and a girl" or "find a dark cover with leaves and a girl"—these operations, which have no text labels and rely purely on visual judgment, can all be accurately recognized and clicked by the AI just like a human.
Core Advantages of Visual Models
Compared to DOM mode, visual models offer the following advantages:
- Higher degree of human-likeness, closer to how humans actually operate visually;
- Lower token consumption and less context usage—no need to load and analyze all DOM elements of the entire page, only operating on the visual target;
- Adaptation to large pages and long workflows, effectively avoiding the context bottleneck of DOM mode.
Visual approaches can likewise add automatic assertions and generate test reports with screenshots—the key lies in clearly telling the AI what to do and what data to save, and encapsulating these fixed tasks into Skills.
Comparison of the Three Approaches and Selection Recommendations
Each of the three AI test automation approaches has its pros and cons; in actual work, they should be used in combination:
| Dimension | Code Scripting (AI Programming) | DOM Parsing Driven | Visual Model (LVM) Driven |
|---|---|---|---|
| Execution Speed | Fastest | Faster (simple pages) | Slower |
| Stability | Highest | Medium (affected by model) | Medium-high |
| Requires Coding | Yes | No | No |
| Token Consumption | None | Higher | Lower |
| Context Pressure | None | Large | Small |
| Applicable Scenarios | Stability + high-speed needs | Small projects/smoke tests | Complex/long workflows/no clear elements |
If you want automation that is both stable and fast, code scripting remains the only choice for now.
Key Reminder: Quality Control Must Not Get Out of Hand
One issue worth watching out for: when AI generates scripts and claims a "100% pass rate," how do you evaluate its quality?
Developers use AI to write code, testers use AI to write code, and then use AI to test another AI—if you don't look at the code logic at all, you won't be able to detect any errors the AI reports during validation. At that point, quality has completely spiraled out of control.
Therefore, ensuring the quality of AI-generated scripts is a required course for test automation professionals in the AI era. Writing code doesn't mean handing everything over to AI—you must have the ability to understand and review the AI's output.
Conclusion: The Real Competitiveness of Test Engineers in the AI Era
In the AI era, programming languages are no longer the barrier. What matters is your programming mindset and your ability to understand AI-generated code.
For testing professionals, true competitiveness lies not in "I can use AI to write test cases," but in:
- Diversified solutions—you can implement all three approaches while others only know one;
- Deliverable achievements—tangible outputs like encapsulating frameworks into Skills, integrating AI with the browser, and developing visual testing tools;
- Building an AI quality engineering system—connecting standards, test cases, scripts, performance testing, and other stages with AI Agent, Skill, and LLM technologies.
This is a new track, meaning everyone starts at the same starting line. But just like in the automation era, it will ultimately go through survival of the fittest—those who can build the entire system will continue to be recognized, while roles that remain merely at the tool-usage level will face greater pressure. Mastering the core methodology is what gives you the confidence to weather the cycles.
Related articles

The Truth Behind Codex 'Build a Website in 5 Minutes': AI Isn't Creating Sites—It's Helping You Copy Them
Exposing the truth behind viral Codex 5-minute website videos: creators aren't building original sites with AI—they're copying shared prompts or scraping others' work. Learn AI coding tools' real limits.

Getting Started with AI Agent Development: A Complete Guide from Concept to Practice
A comprehensive guide to AI Agent architecture and development, covering automated marketing, intelligent customer service, and investment analysis scenarios with single and multi-agent collaboration.

The Truth Behind Codex 'Build a Website in 5 Minutes': AI Isn't Creating Sites — It's Helping You Copy Them
Exposing the truth behind viral Codex 5-minute website videos: creators aren't building original sites with AI — they're copying shared prompts or scraping others' work.