Riju is an automation professional with over 17 years of experience in automating software applications using a broad range of tools including Playwright, Robot Framework, Selenium, Squish, Cypress, Appium, Detox, QTP/UFT and more. He is proficient in Python, Java, JavaScript, C#, VBScript and VBA for automation and has specialized in implementing automation frameworks for applications built across various technologies such as .Net, Java, React Native, QT and others.
Social Share
I built AI Agents to handle my test automation, and they immediately tried to unionise.
I’ve been doing test automation for long enough that I can spot a flaky test from far away, with the sixth sense of a person who has been personally betrayed by “WaitForTimeout(5000)” more times than they’ll admit in polite company.
So, when AI agents started looking like the next logical step – “What if my framework could think?”, I did what any sensible automation architect would do:
I built a small army of agents to help with test automation tasks, and then spent a week debugging why one of them kept confidently “fixing” things that were never broken.
This is the story of how I built them (LangChain + Python + Playwright + MCP vibes), the problems I ran into, and how I got the agents to stop acting like extremely confident interns with admin access.
The Dream: A Tiny QA CoE in My Laptop
The vision was simple:
I feed user stories, BRDs, URLs and API specs
Agents generate:
Page models / POMs (Playwright-based)
Manual test cases
Gherkin scenarios
Automated tests using the POM and business methods
API test matrices
Utility code (DB, PDF, mail, logs)
Execution + reporting
Log analysis and “why did this fail” summaries
Basically: a “Test Automation Factory” where I do the thinking once and agents do the repetitive work 100 times, without getting bored, asking for coffee, or resigning after a sprint retrospective.
The Cast: My Agent Sitcom Ensemble
Here’s the squad I ended up with:
Framework Creator Agent “Give me your stack, I’ll scaffold the repo, structure, configs, runners, CI templates.”
POM / Page Model Agent (Playwright + MCP-style browser control) “I’ll open the page, inspect elements, and generate page objects.”
Manual Test Creation Agent (RAG-powered) “I’ll read requirements, past defects, domain rules, and produce sensible manual tests.”
Page-level Test Creator Agent “I’ll create test cases per screen/component with positive/negative/edge coverage.”
Gherkin Test Creation Agent “I speak fluent Given-When-Then, occasionally with an accent.”
Execution Agent “I’ll run suites, collect artifacts, and package reports like a delivery service.”
Log Analysis Agent “I’ll parse the failure, correlate traces, and tell you what actually broke.”
And of course…
The ‘RAG Somewhere’ Agent This one doesn’t do much, but it makes sure we say “RAG” often enough to sound expensive.
Problem #1: The Agents Were Overconfident (A.K.A. “Hallucination with Swagger”)
Early version output looked like this:
“I fixed the selectors and improved stability.” (No you didn’t. You renamed everything and broke three pages.)
The agent wasn’t lying maliciously. It just had what I call the Energy of a golden retriever: happy, helpful and certain it brought you the correct stick. Even if the stick is your neighbour’s Wi-Fi router.
How I fixed it
I stopped letting agents “free-write” code and switched to structured outputs:
JSON schemas for actions (create_file, update_file, add_test, explain_failure)
Strict tool boundaries (agents can propose; only tools can write)
“Confidence + evidence required” rule:
If you claim an element exists, show how you found it (selector strategy / DOM hint).
If you claim a fix, reference the failing log line/stack trace.
Also: I permitted agents to say “I don’t know” (shockingly effective).
Problem #2: Playwright + Real Apps = “Welcome to Authentication Hell”
In demos, everything is sunshine:
Go to the URL
Click login
Done
In reality, enterprise apps go:
redirect to SSO
2FA
session tokens
“Your password expired”
“Your admin has changed your policy”
a captcha appears like a final boss
One agent tried to “solve” MFA by recommending I “disable MFA in production.” The agent is no longer invited to architecture meetings.
How I fixed it
I implemented three practical strategies:
Storage State + Known Test Accounts Log in once manually, save storageState, reuse it for agent runs.
Auth Adapters A plug-in style auth handler:
SSO cookie mode
API token mode
pre-seeded user session mode
Fallback Mode If login gets weird, agent switches to:
generate page models from accessible pages
or generate tests based on screenshots + DOM snapshots
or ask for a “post-login URL” and continue from there
No drama, no false heroics.
Problem #3: Flaky Selectors and the “Div Soup” Disaster
The first time my POM agent saw a modern UI framework page, it produced selectors like:
div > div > div:nth-child(2) > div > div > button
This is not a selector. This is a cry for help.
How I fixed it
I added a selector policy:
Priority order
data-testid, data-test, data-qa
accessibility (getByRole, getByLabel, getByText with constraints)
stable attributes (name, aria-* when consistent)
last resort: CSS/XPath, but only with anchoring + uniqueness check
And I made the agent prove uniqueness:
highlight count
strict mode checks
“does it still match after re-render?”
The agent now chooses selectors like an adult.
Problem #4: “It Works on My Machine” (Now Featuring Python Environments)
Agent runs started failing with classics:
ModuleNotFoundError
Playwright browsers not installed
version mismatch between pydantic, langchain, and the universe
Windows paths behaving like they’re haunted
How I fixed it
I treated the agent system like a product, not a pile of scripts:
One command bootstrap
create venv
install requirements
install playwright browsers
validate with a health check
A dedicated doctor command:
prints versions
validates tool access
confirms browser launch
checks vector store connectivity
The “doctor” command saved my sanity and possibly my hairline.
Problem #5: RAG Didn’t Magically Make My Agents Smart (It Made Them Confidently Misled)
I plugged in RAG expecting enlightenment.
Instead, the agent started quoting random paragraphs like:
“As per the document…” …and then referenced a section about holiday policies while generating OTP API tests.
How I fixed it
RAG got disciplined:
Better chunking (by headings/meaning, not arbitrary token slices)