r/Playwright • u/Financial_Bar_9593 • May 27 '26
Playwright CLI vs Playwright MCP
Hi I’m a new tester and I want to understand the AI testing world.
So I heard about PW cli and mcp but I don’t know which one to use.
My automations are written in page object model and a heard that one of these tools combined with ai capabilities can writes pages files alone and tests .
Can some one help me to understand
5
5
u/mmasetic May 27 '26
If you like to work from terminal and combing other tools, playwright cli is very efficient to work with. MCP feels to me more natural choice when working in IDE like Windsurf or VSCode where MCP and Tools are visible and transparent.
Just think about installing playwright skill when using playwright cli. Agent has access to all tools available in MCP, but when working from cli agent might execute command with argument --help to understand available calls. This solves skill very efficient.
5
u/AimToMisbehave May 27 '26
Playwright CLI is superior, my team has taken inspiration from the Test Dino team and created a playwright-cli skill which hooks into Claude or Copilot. It uses 50% less tokens than Playwright MCP.
1
u/road2bitcoin May 27 '26
Do you mind sharing the skills you are using? Currently playwright cli comes with some default skills not sure what else we can add and improve?
3
u/AimToMisbehave May 28 '26
Checkout the blog I've linked above, it links through to the test dino github project with some sample skills. We cherry picked some areas of playwright we wanted our agents to become experts in and used claude to customise the agents further.
3
u/_Invictuz May 28 '26
From experience Playwright MCP is much slower, costlier and thus only beneficial in very specific scenarios which I have yet to think of. Therefore I'm using Playwright CLI plus the playwright-cli skill installed via CLI with my AI agent.
2
u/Deep_Ad1959 May 28 '26 edited May 29 '26
codegen and mcp are doing different things. codegen records your interactions and emits a flat script with whatever locators it could resolve, but it doesn't discover scenarios on its own, doesn't structure into pages, and can't follow flows you didn't click through. mcp gives a coding agent live browser access but it doesn't crawl either, you still drive every step. auto-generated page objects need a third thing: a crawler that explores the app, identifies stable flows, and emits POM-shaped files. on the open source side that's the lane i ship in, point it at a url and it produces real playwright files (page objects plus tests) with role/text-first locators so most refactors don't touch them.
fwiw the open-source lane I mentioned is assrt, a crawler I built that auto-discovers scenarios and emits real playwright page objects with role/text-first locators so refactors don't break them, https://assrt.ai/r/r5jpppi8
1
u/Warm-Camera-3520 May 29 '26
The disadvantage of Playwright MCP is the cost. To make it more cost effective, in fact to be able to provide meaningful accurate outputs from the first try, we have actually upgared Playwright MCP to be able to the DOM and work much more accurate with locators. It's open sourced, details are here https://www.treegress.com/treegress-mcp-browser
Maybe you find it useful for you
1
u/Financial_Bar_9593 May 27 '26
Thank you for your explanation. Do you know if the PW cli has the feature that I need(writing me the pages files ) I need him to locate all the elements and writing the best locators for these elements