<?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: ralph van der horst</title>
    <description>The latest articles on DEV Community by ralph van der horst (@ralph_vanderhorst_8a2be).</description>
    <link>https://dev.to/ralph_vanderhorst_8a2be</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%2F4255176%2F8a2a2552-4f3b-454b-a51f-30e726361a9d.png</url>
      <title>DEV Community: ralph van der horst</title>
      <link>https://dev.to/ralph_vanderhorst_8a2be</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ralph_vanderhorst_8a2be"/>
    <language>en</language>
    <item>
      <title>I built Playwright-style AI test agents for Selenium</title>
      <dc:creator>ralph van der horst</dc:creator>
      <pubDate>Fri, 20 Nov 2026 08:14:08 +0000</pubDate>
      <link>https://dev.to/ralph_vanderhorst_8a2be/i-built-playwright-style-ai-test-agents-for-selenium-13g7</link>
      <guid>https://dev.to/ralph_vanderhorst_8a2be/i-built-playwright-style-ai-test-agents-for-selenium-13g7</guid>
      <description>&lt;h2&gt;
  
  
  Why I built it
&lt;/h2&gt;

&lt;p&gt;Playwright now ships AI test agents: a planner that explores your app and writes a test plan, a generator that turns the plan into tests, and a healer that fixes them when they break. It is one of the most useful things to happen to test automation in years.&lt;/p&gt;

&lt;p&gt;But a lot of teams run Selenium: Python, Java or C# suites, Selenium Grid, years of tests that work. So I built the same workflow for Selenium: &lt;strong&gt;Selenium AI Agent&lt;/strong&gt;, an open-source MCP server.&lt;/p&gt;

&lt;p&gt;In this post I walk through a real run on a practice web shop: one prompt to a structured test plan, a second prompt to running pytest tests, an HTML report, and a real bug the tests found on the way.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Selenium AI Agent is
&lt;/h2&gt;

&lt;p&gt;Selenium AI Agent lets an AI assistant drive a real browser through Selenium WebDriver, and gives it the tools to plan, generate, run and repair tests.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Built in Node.js:&lt;/strong&gt; run it with &lt;code&gt;npx -y selenium-ai-agent&lt;/code&gt;; the matching ChromeDriver is downloaded for you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Works in your AI client:&lt;/strong&gt; Claude Desktop, Claude Code, VS Code (GitHub Copilot agent mode) and Cursor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Python + pytest by default:&lt;/strong&gt; generated tests are Python unless you ask for something else, such as Java, C#, JavaScript/TypeScript, WebdriverIO or Robot Framework.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test agents like Playwright's:&lt;/strong&gt; a planner, a generator and a healer, which &lt;code&gt;init-agents&lt;/code&gt; installs in your project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Selenium Grid:&lt;/strong&gt; parallel sessions on Chrome, Firefox and Edge.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: the planner explores the shop and writes a test plan
&lt;/h2&gt;

&lt;p&gt;The first prompt is plain English:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Explore the shopping section of practiceautomatedtesting.com and create a test plan for the shopping cart and checkout.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The planner opens the shop in Chrome and takes an inventory of each page: every field with its label and test id, every button, every link. When a pop-up opens, such as the product details or the checkout, it looks only inside the pop-up, so the plan is about what the user actually sees.&lt;/p&gt;

&lt;p&gt;The result is &lt;code&gt;specs/shopping-cart-and-checkout.md&lt;/code&gt;, in the same structure as Playwright's planner: &lt;strong&gt;2 suites, 8 tests and 16 steps&lt;/strong&gt;, each step with its own expected results. One test from the plan:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;#### 1.1. Add a product from the grid
&lt;/span&gt;
&lt;span class="gs"&gt;**File:**&lt;/span&gt; &lt;span class="sb"&gt;`tests/cart/test_add_from_grid.py`&lt;/span&gt;

&lt;span class="gs"&gt;**Steps:**&lt;/span&gt;
  1. Open the shop
    &lt;span class="k"&gt;- &lt;/span&gt;expect: The heading shows "Search Results (10 products)"
    &lt;span class="k"&gt;- &lt;/span&gt;expect: The cart button shows "0 items" and "$0.00"
  2. Click "Add to Cart" for the Mechanical Keyboard
    &lt;span class="k"&gt;- &lt;/span&gt;expect: The cart button shows "1 items"
    &lt;span class="k"&gt;- &lt;/span&gt;expect: The cart total is "$89.99"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On top of Playwright's format, the plan keeps two extras: a table of the &lt;strong&gt;elements&lt;/strong&gt; it found, with stable locators (the shop's &lt;code&gt;data-testid&lt;/code&gt;s), and the &lt;strong&gt;gaps&lt;/strong&gt;. The shop's own test scenarios mention quantity buttons and a "Your cart is empty" message that don't exist, so the planner lists them as questions for the product owner instead of inventing tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: the generator turns the plan into pytest tests
&lt;/h2&gt;

&lt;p&gt;The second prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Generate Selenium tests from specs/shopping-cart-and-checkout.md, run them, and show me the test report.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The generator writes one test file per plan test, at the path the plan gives, with one assertion for every &lt;code&gt;expect&lt;/code&gt;. Before it writes an assertion, it checks the value live in the browser: the $89.99, the 21% VAT on the order summary, the iDeal bank list. No language was named, so it uses the default, Python with pytest, and sets up a virtual environment with Selenium and pytest in the project.&lt;/p&gt;

&lt;p&gt;Plan test 1.1 became this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="s2"&gt;"""Plan 1.1: Add a product from the grid (specs/shopping-cart-and-checkout.md)."""&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;common&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;by&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;By&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_add_from_grid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;shop&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# 1. Open the shop (done by the shop fixture)&lt;/span&gt;
    &lt;span class="c1"&gt;# expect: The heading shows "Search Results (10 products)"&lt;/span&gt;
    &lt;span class="n"&gt;heading&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;shop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;XPATH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"//h2[contains(., 'Search Results')]"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="s2"&gt;"Search Results (10 products)"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# expect: The cart button shows "0 items" and "$0.00"&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="s2"&gt;"0 items"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;shop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cart_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="s2"&gt;"$0.00"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;shop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cart_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# 2. Click "Add to Cart" for the Mechanical Keyboard&lt;/span&gt;
    &lt;span class="n"&gt;shop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_to_cart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# expect: The cart button shows "1 items"&lt;/span&gt;
    &lt;span class="c1"&gt;# expect: The cart total is "$89.99"&lt;/span&gt;
    &lt;span class="n"&gt;shop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait_for_cart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"$89.99"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;shop&lt;/code&gt; fixture in &lt;code&gt;conftest.py&lt;/code&gt; keeps each test short: open the shop, click by test id (scrolled clear of the sticky header), wait for the cart. The &lt;code&gt;# expect:&lt;/code&gt; comments line up one-to-one with the plan, so a reviewer can check the test against the plan line by line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: the tests run, and find a real bug
&lt;/h2&gt;

&lt;p&gt;Seven tests pass. The eighth, "close the checkout without ordering", fails, and it is right to.&lt;/p&gt;

&lt;p&gt;The checkout is about 1,040 px tall and sits centred in a fixed, full-screen overlay. In a browser window shorter than about 1,070 px, the top of the checkout falls off the screen, and you cannot scroll back up to it. The close button is up there. On most laptop screens, a real user cannot close the checkout. Selenium reports the button as not visible, because it isn't.&lt;/p&gt;

&lt;p&gt;I kept the test honest: it is marked as a known bug with &lt;code&gt;xfail(strict=True)&lt;/code&gt;. The suite stays green, and the day the shop is fixed, pytest reports that the test unexpectedly passes.&lt;/p&gt;

&lt;p&gt;Every run writes two reports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;reports/report.html&lt;/code&gt;&lt;/strong&gt; (pytest-html): the application, the test plan and the Chrome version; a summary with filters; a "Plan test" column that links each result to its test in the plan; and a screenshot of the browser for every failure. The bug's screenshot shows the checkout with its top cut off.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;reports/junit.xml&lt;/code&gt;&lt;/strong&gt;: for Jenkins, GitHub Actions or Azure DevOps.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it yourself
&lt;/h2&gt;

&lt;p&gt;You need Node.js 18+ and Chrome. Pick your client:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude Code&lt;/strong&gt;, plus the planner, generator and healer as subagents in your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add selenium-mcp -- npx -y selenium-ai-agent
npx selenium-ai-agent init-agents --loop=claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Claude Desktop&lt;/strong&gt; (&lt;code&gt;claude_desktop_config.json&lt;/code&gt;) and &lt;strong&gt;Cursor&lt;/strong&gt; (&lt;code&gt;~/.cursor/mcp.json&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"selenium-mcp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"selenium-ai-agent"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&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;&lt;strong&gt;VS Code / GitHub Copilot&lt;/strong&gt; (&lt;code&gt;.vscode/mcp.json&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"servers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"selenium-mcp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"selenium-ai-agent"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&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;Then ask it to plan tests for your own app. Run &lt;code&gt;npx selenium-ai-agent doctor&lt;/code&gt; if something doesn't start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Watch the demos
&lt;/h2&gt;

&lt;p&gt;Both steps are on my YouTube channel as short demos with a voice-over: the planner exploring the shop and writing the plan, and the generator writing, running and reporting the tests.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;YouTube:&lt;/strong&gt; &lt;a href="https://www.youtube.com/@ralphvanderhorst5193/videos" rel="noopener noreferrer"&gt;Ralph van der Horst&lt;/a&gt;, about learning test automation in the world of AI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/learn-automated-testing/selenium_agent" rel="noopener noreferrer"&gt;learn-automated-testing/selenium_agent&lt;/a&gt;, open source; a star helps others find it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;npm:&lt;/strong&gt; &lt;a href="https://www.npmjs.com/package/selenium-ai-agent" rel="noopener noreferrer"&gt;selenium-ai-agent&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Practice site used in the demos:&lt;/strong&gt; &lt;a href="https://practiceautomatedtesting.com" rel="noopener noreferrer"&gt;practiceautomatedtesting.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Courses and articles:&lt;/strong&gt; &lt;a href="https://learnautomatedtesting.com" rel="noopener noreferrer"&gt;learnautomatedtesting.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next up is the healer: changing the shop and watching the tests repair themselves. What would you want to see in that demo? Let me know in the comments.&lt;/p&gt;

</description>
      <category>agents</category>
      <category>ai</category>
      <category>automation</category>
      <category>testing</category>
    </item>
    <item>
      <title>I built Playwright-style AI test agents for Selenium</title>
      <dc:creator>ralph van der horst</dc:creator>
      <pubDate>Fri, 20 Nov 2026 07:40:39 +0000</pubDate>
      <link>https://dev.to/ralph_vanderhorst_8a2be/-title-i-built-playwright-style-ai-test-agents-for-selenium-published-false-description-an-5f74</link>
      <guid>https://dev.to/ralph_vanderhorst_8a2be/-title-i-built-playwright-style-ai-test-agents-for-selenium-published-false-description-an-5f74</guid>
      <description></description>
      <category>agents</category>
      <category>ai</category>
      <category>automation</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
