<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pluswithai</title>
    <description>The latest articles on DEV Community by Pluswithai (@pluswithai).</description>
    <link>https://dev.to/pluswithai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4227239%2F927b6359-789c-4396-9e31-9b1d6e1f2d99.png</url>
      <title>DEV Community: Pluswithai</title>
      <link>https://dev.to/pluswithai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pluswithai"/>
    <language>en</language>
    <item>
      <title>Solving Flaky Playwright Tests: How We Automated E2E Generation with an AI Agent and MCP</title>
      <dc:creator>Pluswithai</dc:creator>
      <pubDate>Wed, 04 Nov 2026 22:19:14 +0000</pubDate>
      <link>https://dev.to/pluswithai/solving-flaky-playwright-tests-how-we-automated-e2e-generation-with-an-ai-agent-and-mcp-1dho</link>
      <guid>https://dev.to/pluswithai/solving-flaky-playwright-tests-how-we-automated-e2e-generation-with-an-ai-agent-and-mcp-1dho</guid>
      <description>&lt;p&gt;Every developer knows the dread of seeing a green CI pipeline turn red because of an end-to-end test failure after a harmless frontend update.&lt;/p&gt;

&lt;p&gt;You change a Tailwind class, reorder a flexbox container, or update an icon, and suddenly three Playwright specs break. The underlying logic works perfectly, but the tests were coupled to brittle DOM structures or arbitrary class names.&lt;/p&gt;

&lt;p&gt;Maintaining E2E test suites is one of those engineering tasks we know is critical, but teams often push aside because scaffolding and debugging selectors feels like an endless chore.&lt;/p&gt;

&lt;p&gt;In this post, I want to break down an architectural approach to solving this: using an autonomous AI agent that explores web apps, infers user journeys, and generates standard Playwright code with MCP support.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Three Core Bottlenecks of Modern E2E Testing
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Brittle Locators: Tests relying on CSS classes (.btn-primary-v2) or deep XPath selectors break constantly. Modern frontends with utility CSS or CSS modules make this even worse.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scaffolding Friction: Writing boilerplate for auth flows, form validations, and navigation paths takes valuable engineering hours.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Vendor Lock-in Trap: Many modern AI testing tools hide your tests inside proprietary black-box runners or cloud dashboards. If you cancel your subscription, you lose your entire test suite.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Agentic Approach: Exploration Over Recording
&lt;/h2&gt;

&lt;p&gt;Traditional test recorders simply watch where you click and record raw coordinates or selectors. Instead, an agentic model interacts with the web application like a human QA engineer:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Semantic DOM Inspection
&lt;/h3&gt;

&lt;p&gt;Rather than scraping raw CSS selectors, the agent analyzes the page's Accessibility Tree and semantic structure. It identifies interactive elements by their functional roles (role="button", accessible labels, and ARIA attributes), matching how actual users perceive the UI.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Autonomous Journey Mapping
&lt;/h3&gt;

&lt;p&gt;The agent crawls the application dynamically, discovering actionable paths: signup flows, navigation states, filter updates, and checkout steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Emitting Standard Playwright Code
&lt;/h3&gt;

&lt;p&gt;The most important design decision: no proprietary formats. The output must be idiomatic Playwright TypeScript code using standard practices like page.getByRole() and page.getByLabel():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;completes user onboarding flow&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/signup&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Using resilient accessible locators rather than brittle class names&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByLabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Email address&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dev@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByLabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SecurePassword123!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Create account&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="c1"&gt;// Validate state progression&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getByRole&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;heading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Welcome aboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})).&lt;/span&gt;&lt;span class="nf"&gt;toBeVisible&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because it outputs standard files, you can commit them directly to your Git repository, run them locally, or plug them into your existing GitHub Actions pipeline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrating with Developer Workflows: CLI &amp;amp; MCP
&lt;/h2&gt;

&lt;p&gt;Developers don't want to live inside another isolated web dashboard. Testing belongs inside the developer loop.&lt;/p&gt;

&lt;p&gt;To bridge this gap, we built support for two developer interfaces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A CLI tool (&lt;a class="mentioned-user" href="https://dev.to/pluswithai"&gt;@pluswithai&lt;/a&gt;/cli): Run explorations and trigger isolated cloud test executions straight from your terminal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Model Context Protocol (MCP) Server: By providing an MCP server, environments like Cursor, Claude Desktop, or agent-enabled IDEs can directly interface with the test engine. You can ask your agentic IDE to "explore my staging app and generate a Playwright suite for the checkout flow", and the tool will execute the exploration and return the code to your editor.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where We're Headed (and Current Challenges)
&lt;/h2&gt;

&lt;p&gt;We built this architecture into &lt;a href="https://pluswithai.com" rel="noopener noreferrer"&gt;Pluswithai&lt;/a&gt; (&lt;a href="https://pluswithai.com" rel="noopener noreferrer"&gt;https://pluswithai.com&lt;/a&gt;), an agent that explores your site, writes standard Playwright suites, and runs them on a schedule in isolated cloud browsers.&lt;/p&gt;

&lt;p&gt;Building autonomous testing agents is an ongoing engineering challenge. Right now, our focus is on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handling multi-factor authentication (MFA) and complex single-sign-on (SSO) edge cases cleanly.&lt;/li&gt;
&lt;li&gt;Managing realistic mock database states for destructive operations (e.g., deleting a tenant or cancelling subscriptions).&lt;/li&gt;
&lt;li&gt;Auto-healing selectors when fundamental UI redesigns happen.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try It Out &amp;amp; Give Us Your Feedback
&lt;/h2&gt;

&lt;p&gt;We're currently running an open trial (no credit card required, no waitlist) so developers can test it on their own web apps and see how it handles their flows:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://pluswithai.com" rel="noopener noreferrer"&gt;Visit Pluswithai&lt;/a&gt; - &lt;a href="https://pluswithai.com" rel="noopener noreferrer"&gt;https://pluswithai.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'd love to hear from other engineers maintaining Playwright or Cypress suites:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is currently your most painful source of test flakiness?&lt;/li&gt;
&lt;li&gt;What features would you like to see exposed through an MCP server for test automation?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Leave a comment below—I'll be actively answering technical questions about the architecture and how it works under the hood!&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>ai</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
