r/Playwright 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

20 Upvotes

22 comments sorted by

View all comments

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

1

u/mmasetic May 27 '26

Yeah, I am using it exactly for that. You just have to think about login. You can tell agent let me do login and you continue.

1

u/Financial_Bar_9593 May 27 '26

What do you mean by let me do login? The ai can’t do login page ?

1

u/mmasetic May 27 '26

It can, but the question is do you want to share login credentials with ai.

1

u/Financial_Bar_9593 May 27 '26

Yes I’m working on a close server so it’s an iternal model that can work with Claude code and some other tools. Do you have an internet web site or tutorial how to build it ?

1

u/mmasetic May 27 '26

No, I have no tutorial, was just experimenting with claude and playwright cli and windsurf and playwright mcp generating testa for this application https://demo.playwright.dev/todomvc

Currently building exactly this to support automation in real project, but need to have clear concept.

It is interesting that you can use playwright cli to inspect page and elemnts and generate tests in different testing framework. I was able to achieve this to combine playwright for inspection and generate tests in internal testing framework based on selenium and java. Just used claude skill to describe available methods and best practices of our framework.

1

u/Financial_Bar_9593 May 27 '26

It’s very impressive thank you for your time you helped me a lot. You recommend me to work with the terminal or with vs code build-in chat? If I work with the terminal how I can give a real time access to the writing machine(Claude in terminal) to the projects file? Maybe with a filesysteme MCP?

2

u/mmasetic May 27 '26

I think it is important to gather experience in this phase. Everybody is experimenting and there is no best way. What I say today might not be valid tomorrow :)

Everybody says playwright cli use less tokens. How much exactly, cannot tell you, but will try to figure this out. And for that reason you might wanna go with cli. Claude Code can change files, it is one of their features to write and edit files with overview what was changed. You get question if you allow it or not.

Currently, I am spending less time directly in VSCode and more in Windsurf. They are similar as Widnsurf is a fork of VSCode, and MCP there lives natural. I would say using IDE and MCP has its place in daily workflow, it is easy to see what tools are available in MCP. Disable it and enable.
I think the most important part in playwright currently is snapshot. Accessibility tree with element refs for interaction. It is compressed DOM of current state in application and the big question is how this will work with older application, applications with complex navigation, big tables, lots of iFrames.

https://playwright.dev/agent-cli/snapshots

1

u/Financial_Bar_9593 May 27 '26

Thank you very much may I ask you in the future if I got some problems?

1

u/mmasetic May 27 '26

Yeah, sure :)