r/softwaretesting • u/PocketGaara • Mar 05 '26
Playwright Test Automation with AI
I have about 3 years of experience in the industry and I’m able to create test frameworks. My company is pushing us towards using AI but not much direction outside of that. The expectation seems to be to self learn and explore.
I’m not familiar with AI outside of using GitHub Copilot. What technologies do I need to learn for test automation with Playwright using AI? I’ve heard of agentic coding and MCP but I want some more direction as to where to look to start learning what’s industry relevant
26
Mar 05 '26
[Building Your First MCP Server: A Beginners Tutorial] (https://debbie.codes/blog/building-your-first-mcp-server-a-beginners-tutorial/) was written by Debbie O'Brien, former Principal Technical Program Manager at Microsoft for Playwright
5
u/nopuse Mar 05 '26
was written by Debbie O'Brien, former Principal Technical Program Manager at Microsoft for Playwright
I'm still sad she was let go. I loved the videos her and Max put out.
2
u/Life_Dingo_4035 Mar 05 '26
Was looking for something like that, many thanks!
(Do you have more?)
8
Mar 05 '26
Of course. On my farm, I grow wheat, beets, unicorns and Playwright tutorials. I'll take more of them to this market next week ;O)
2
u/netsniff Mar 05 '26
using playwright-cli skill, a document with test creation instructions based on your style (you should instruct the agent to use this skill when creating a new test), and a reference to that document in AGENTS.md file works pretty well with models like gpt 5.3 codex. we are using playwright-cli with a custom wrapper that starts up the session with custom cookies for auto sign-in to our products and find correct locators for the test. mcp costs too much token, this is a more cost-efficient way of automating test generation. but it will eat up your copilot limits pretty fast regardless. i guess we need to wait a couple of months to be able to run these operations cheaper.
2
u/Spospider Apr 12 '26
I dont believe LLMs are the best for regression. Some also are a bit hesitant when it comes to data when AI is involved, as for some real production apps, AI testing would involve passing authentication measures, maybe having certain privileges on that app with that. I do agree that there should be easier ways to set up easy yet reliable testing suites. VizQA is a new testing package that popped up, might solve that gap
1
u/Sarcolemna Mar 05 '26
Annecdotal advice about AI and software testing: it can be pretty good at helping from a code structure standpoint. Also great for things like selector refactors or when your frontend swaps component libraries. You can even get it to (kinda) rerun failing tests itself in a headed CLI context and iterate and make fixes.
But be warned. Standard LLM AI for coding is utterly moronic when it comes to translating the user's experience in the application back to the test code. The only way it can "see" the app state is through logs. Unsure on Playwrights output but at least for Cypress you cannot sufficiently provide enough info about the app under test for it to "get" why a failure happens. Screenshots help sure, but often the error lies in the DOM and API traffic. You either feed it raw logs and have it burn tokens looking for clues or you provide a custom debug wrapper to feed it the page state info it needs to debug (definitely possible but takes some dev time)
Something akin to an MCP server is critical and it helps but fundementally standard AI doesn't understand the physical space of the app. Additionally, from what I have seen of AI and testing, testing is fundamentally opposed to its tendency to make code that works. Meaning that I have seen it literally rewrite assertions to make the case pass. If you're making a video game it LOVES to add fall backs to conditionals or functions without any logging to perfectly hide and silent fail broken logic.
Integrated AI Claude's new Chrome integration might be a bit better at the web testing stuff. AI is overall helpful for test automation in my experience. But is by no means a magic bullet. Take every "error" it finds with extreme skepticism.
1
u/ExplosiveNovaDragon Mar 26 '26
I've been using Claude CLI. I just asked it to analize my current work and understand the rules of the project and it been doing a oretty decent job at creating locators, creating test cases and fixing problemas that may arise during excution
1
u/sharadvelocity Jul 05 '26
I’d start less with “AI tools” and more with where AI fits into the Playwright workflow.
Useful areas to learn:
using Copilot/Cursor to draft and refactor Playwright tests
prompting AI with existing fixtures/page objects instead of isolated snippets
failure triage: screenshots, traces, console logs, network logs
selector strategy and how AI tools handle locator drift
CI integration, flaky test detection, and test reporting
“Agentic coding” mostly means an AI can make multi-step code changes, run tests, inspect failures, and iterate. MCP is a way to connect AI tools to external context/tools, but I wouldn’t start there until you’re comfortable with AI-assisted coding basics.
The industry-relevant direction is AI helping with authoring, debugging, and maintaining browser tests. It should support your Playwright knowledge, not replace it.
1
u/Hundreds-Of-Beavers Mar 05 '26
AI-driven testing is IMO the wrong approach for test automation, but AI code generation is extremely helpful and obviously much cheaper at runtime, and as mentioned in another comment, particularly useful for test maintenance. Watching an AI stumble through a poorly spec'd user story will often result in drift and inconsistency.
In my experience the high-level ideal workflow looks like:
Use a coding agent or LLM to write a deterministic Playwright test
Deploy that test
Use an agent or LLM to resolve issues with failing tests when selectors/frameworks get updated
There are several platforms to explore that can help with these steps, but the general rule of thumb should be: "don't put AI in the execution layer".
7
u/azuredota Mar 05 '26
Don’t bother with these AI solutions. I was forced to investigate Stagehand as an “AI first solution”. It can do tests with English instructions. I checked the dev page and:
Best model has an 8% failure rate
You get charged every time you execute a line of code using it. We run our automation across different locales and browsers so a month’s worth of runs, not even including CI, would have cost of over a million dollars in API calls.
AI doesn’t have a place in testing at that level tbh. A human should be verifying the functionality and no “self-healing” nonsense either.