<?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: Ankit Anand</title>
    <description>The latest articles on DEV Community by Ankit Anand (@ankianan).</description>
    <link>https://dev.to/ankianan</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2288826%2F8c56ffc3-099d-452d-991e-7bca2e148d7e.png</url>
      <title>DEV Community: Ankit Anand</title>
      <link>https://dev.to/ankianan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ankianan"/>
    <language>en</language>
    <item>
      <title>Enhance debugging selenium with chrome devtools mcp</title>
      <dc:creator>Ankit Anand</dc:creator>
      <pubDate>Sun, 17 May 2026 14:04:30 +0000</pubDate>
      <link>https://dev.to/ankianan/enhance-debugging-selenium-with-chrome-devtools-mcp-459p</link>
      <guid>https://dev.to/ankianan/enhance-debugging-selenium-with-chrome-devtools-mcp-459p</guid>
      <description>&lt;p&gt;Debugging a browser-based E2E test is fundamentally harder than debugging a unit or component test.&lt;/p&gt;

&lt;p&gt;With unit tests, failures are usually deterministic and isolated. You have stack traces, local state, and direct control over execution flow. Browser automation is different. Failures often emerge from runtime behavior spread across:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;asynchronous UI rendering&lt;/li&gt;
&lt;li&gt;network timing&lt;/li&gt;
&lt;li&gt;overlays and animations&lt;/li&gt;
&lt;li&gt;stale DOM state&lt;/li&gt;
&lt;li&gt;hydration mismatches&lt;/li&gt;
&lt;li&gt;browser APIs&lt;/li&gt;
&lt;li&gt;authentication flows&lt;/li&gt;
&lt;li&gt;race conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a result, developers rely heavily on evidence collected after failure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;screenshots&lt;/li&gt;
&lt;li&gt;videos&lt;/li&gt;
&lt;li&gt;HAR files&lt;/li&gt;
&lt;li&gt;console logs&lt;/li&gt;
&lt;li&gt;Selenium traces&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While useful, these artifacts only capture fragments of what happened. Developers still need to manually correlate the evidence and reconstruct the failure.&lt;/p&gt;

&lt;p&gt;But what if AI could investigate the browser directly?&lt;/p&gt;

&lt;p&gt;That is where Chrome DevTools MCP becomes interesting.&lt;/p&gt;




&lt;h2&gt;
  
  
  From Static Artifacts to Live Browser Investigation
&lt;/h2&gt;

&lt;p&gt;Chrome DevTools MCP allows AI agents to connect to a running Chrome instance and interact with browser DevTools programmatically.&lt;/p&gt;

&lt;p&gt;Instead of analyzing only logs and screenshots, an AI agent can inspect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;live DOM state&lt;/li&gt;
&lt;li&gt;console errors&lt;/li&gt;
&lt;li&gt;network activity&lt;/li&gt;
&lt;li&gt;browser storage&lt;/li&gt;
&lt;li&gt;performance timeline&lt;/li&gt;
&lt;li&gt;accessibility tree&lt;/li&gt;
&lt;li&gt;runtime JavaScript state&lt;/li&gt;
&lt;li&gt;overlays and layout issues&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This changes the debugging model entirely.&lt;/p&gt;

&lt;p&gt;Traditional E2E debugging:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Test failure
   ↓
Collect artifacts
   ↓
Human investigates manually
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;MCP-enabled debugging:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Test failure
   ↓
Pause browser execution
   ↓
AI investigates live browser state
   ↓
AI explains probable root cause
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Using Selenium with Chrome DevTools MCP
&lt;/h2&gt;

&lt;p&gt;In my setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Selenium is used for browser automation&lt;/li&gt;
&lt;li&gt;Jest is used as the test runner&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;vscode-jest&lt;/code&gt; helps debug tests locally&lt;/li&gt;
&lt;li&gt;Chrome DevTools MCP is connected to the running browser session&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The workflow is surprisingly natural.&lt;/p&gt;

&lt;p&gt;When a test fails or reaches a suspicious state, execution can be paused using a breakpoint or &lt;code&gt;debugger&lt;/code&gt; statement. While the browser is paused, the AI agent can inspect the live browser session through MCP.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;css&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[data-testid="checkout"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="k"&gt;debugger&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, instead of manually opening DevTools and exploring the browser state, the AI can directly investigate the issue.&lt;/p&gt;




&lt;h2&gt;
  
  
  Enabling Remote Debugging in Selenium
&lt;/h2&gt;

&lt;p&gt;Chrome needs to expose the DevTools debugging port.&lt;/p&gt;

&lt;p&gt;Example Selenium configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;chrome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;selenium-webdriver/chrome&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;chrome&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Options&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addArguments&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--remote-debugging-port=9222&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once Chrome is running with remote debugging enabled, MCP can attach to the active browser session.&lt;/p&gt;




&lt;h2&gt;
  
  
  What AI Can Investigate
&lt;/h2&gt;

&lt;p&gt;Once connected, the AI agent can answer questions like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Why is the checkout button not clickable?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Find failed network requests since page load
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Check whether an overlay is blocking user interaction
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Compare expected selector against current DOM state
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Find React hydration errors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Check whether stale state was rendered
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Analyze console errors related to authentication flow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is much more powerful than analyzing screenshots after the fact.&lt;/p&gt;

&lt;p&gt;The AI effectively becomes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a frontend engineer&lt;/li&gt;
&lt;li&gt;a QA engineer&lt;/li&gt;
&lt;li&gt;and a DevTools expert&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;attached directly to the running browser session.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Matters for Flaky Tests
&lt;/h2&gt;

&lt;p&gt;Flaky tests are especially painful because the evidence is often incomplete by the time humans inspect the failure.&lt;/p&gt;

&lt;p&gt;By the time logs and screenshots are reviewed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pending promises are gone&lt;/li&gt;
&lt;li&gt;runtime state has disappeared&lt;/li&gt;
&lt;li&gt;event listeners no longer exist&lt;/li&gt;
&lt;li&gt;timing relationships are lost&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With MCP and paused execution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the runtime state is still alive&lt;/li&gt;
&lt;li&gt;pending async operations remain inspectable&lt;/li&gt;
&lt;li&gt;layout state is preserved&lt;/li&gt;
&lt;li&gt;network timing is visible&lt;/li&gt;
&lt;li&gt;React state can still be analyzed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This significantly improves debugging quality for nondeterministic failures.&lt;/p&gt;




&lt;h2&gt;
  
  
  Combining Failure Reports with Live State
&lt;/h2&gt;

&lt;p&gt;One particularly powerful idea is combining:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;historical failure artifacts&lt;/li&gt;
&lt;li&gt;live browser inspection&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Failure reports provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;stack traces&lt;/li&gt;
&lt;li&gt;expected behavior&lt;/li&gt;
&lt;li&gt;previous screenshots&lt;/li&gt;
&lt;li&gt;assertion failures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Meanwhile MCP provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;current browser truth&lt;/li&gt;
&lt;li&gt;runtime state&lt;/li&gt;
&lt;li&gt;live DOM inspection&lt;/li&gt;
&lt;li&gt;network visibility&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Together, the AI can reason about failures causally instead of symptomatically.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“The selector was not found”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;the AI can infer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“The selector was not found because the authentication request failed, causing the React tree to render the guest layout instead of the authenticated checkout flow.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is a major leap in debugging capability.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why MCP Is More Valuable for E2E than Unit Tests
&lt;/h2&gt;

&lt;p&gt;Unit tests already have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;deterministic state&lt;/li&gt;
&lt;li&gt;isolated execution&lt;/li&gt;
&lt;li&gt;strong observability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Browser automation failures are different. They emerge from interactions between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UI rendering&lt;/li&gt;
&lt;li&gt;browser timing&lt;/li&gt;
&lt;li&gt;backend responses&lt;/li&gt;
&lt;li&gt;user interaction simulation&lt;/li&gt;
&lt;li&gt;framework hydration&lt;/li&gt;
&lt;li&gt;CSS/layout behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Chrome DevTools MCP gives AI visibility into these runtime interactions.&lt;/p&gt;

&lt;p&gt;That makes it especially valuable for Selenium and E2E workflows.&lt;/p&gt;




&lt;h2&gt;
  
  
  Recommended Architecture
&lt;/h2&gt;

&lt;p&gt;One important recommendation is to keep the AI debugging layer separate from the test runner itself.&lt;/p&gt;

&lt;p&gt;A clean architecture looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Jest/Mocha + Selenium
       ↓
Failure artifacts
       ↓
Debug orchestration layer
       ↓
Chrome DevTools MCP
       ↓
AI analysis agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This separation helps avoid:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tight coupling between AI and tests&lt;/li&gt;
&lt;li&gt;nondeterministic execution&lt;/li&gt;
&lt;li&gt;CI instability&lt;/li&gt;
&lt;li&gt;polluted test infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The AI should assist debugging, not participate in test execution.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Chrome DevTools MCP changes browser debugging from:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“collect evidence for humans”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;to:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“allow AI to investigate the browser directly”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For Selenium-based E2E automation, this is a meaningful shift.&lt;/p&gt;

&lt;p&gt;Instead of spending hours correlating:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;logs&lt;/li&gt;
&lt;li&gt;screenshots&lt;/li&gt;
&lt;li&gt;HAR files&lt;/li&gt;
&lt;li&gt;videos&lt;/li&gt;
&lt;li&gt;DevTools traces&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;developers can pause execution and let AI inspect the live browser state in real time.&lt;/p&gt;

&lt;p&gt;The result is faster diagnosis, deeper observability, and a far more interactive debugging experience for modern browser automation.&lt;/p&gt;

</description>
      <category>automation</category>
      <category>selenium</category>
      <category>mcp</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
