r/Playwright • • 13h ago

Built an open-source Python Playwright test runner driven by a local LLM (only tested on SauceDemo so far — looking for locator/DOM feedback)

1 Upvotes

Hey everyone, I'm building an open-source Python + Playwright project for my college capstone and wanted to get some Playwright-specific feedback before my final review.

Repo if you want to look at the code: https://github.com/saturn-16/Autonomous-Web-Testing-Agent

The goal was to take a target URL + a plain english prompt (like "add Bolt T-Shirt to cart and go to checkout"), explore the live page using a local LLM (Ollama / llama3.2, with cloud API fallback), and then run an independent pass/fail audit + export HTML/MD/JSON reports with screenshots streamed to a local web UI.

Where Playwright actually ended up doing most of the heavy lifting:

- Control inventory & locator fallback: Instead of letting the LLM write CSS selectors from scratch (which broke constantly), I extract interactive controls from the DOM along with source hints (text, value, placeholder, id) and run a fallback locator chain. I also had to strip out temporary data-agent-id attributes after interacting so injected IDs wouldn't pollute later state comparisons.

- Overlay recovery: When a click gets blocked, it tries closing slide-out menus, role=dialog modals, or sending Escape before marking the action futile.

- Mechanical state/safety checks: Off-domain links are checked via window.location.origin, and each state gets hashed from URL + visible controls so we catch no-op clicks and login error loops instead of burning max steps.

Being completely honest about where this stands: live browser testing has only been run end-to-end on saucedemo.com and local test fixture HTML pages so far. I haven't battle-tested it against messy real-world SPAs, heavy shadow DOM, nested iframes, or dynamic React/Angular hydration quirks yet, and even SauceDemo's final checkout confirmation steps still need work.

Two questions for people who write Playwright every day:

  1. For extracting clickable controls reliably across real SPAs, are there better Playwright patterns (like ARIA/accessibility tree snapshots vs DOM querying) that handle shadow DOM and dynamic modals more cleanly?
  2. Would adding a "record & export a clean deterministic Playwright Python test" after a successful LLM run make this way more practical for real teams, so nobody has to run an LLM in CI?

Appreciate any blunt Playwright advice or code critique!


r/Playwright • • 22h ago

How should I start with Playwright + AI automation?

14 Upvotes

Hey everyone!

I have around 1 year of experience in manual testing and want to move into automation, particularly Playwright with TypeScript and AI testing.

I'm a beginner at coding, so I'm trying to figure out the right way to start.

A few things I'd love your advice on:

  • Should I learn JavaScript first or jump into TypeScript?
  • Which tools should I focus on besides Playwright? (MCP, CLI, Copilot, Claude, ChatGPT, etc.)
  • How are companies actually using AI in automation testing?
  • What practical projects should I build to become job-ready?
  • How can I transition from manual testing into an automation role?
  • What skills are companies looking for when hiring junior automation engineers?

If you were starting today, what would your learning path look like?

I can dedicate around 20–25 hours a week and really want to use my time wisely.

Would love to hear advice from people already working in Playwright, automation, and AI testing.

Thanks!


r/Playwright • • 14h ago

Best Test Orchestration Platforms for Playwright CI

Thumbnail currents.dev
2 Upvotes

Playwright's --shard=x/y splits the suite before the run, and by default it splits by whole test file. If some files hold many more tests than others, one shard runs much longer than the rest. merge-reports then waits for that slowest shard. One failed test or one dead runner can also force a rerun of far more tests than the ones that broke.

We compared 10 tools that try to fix this: Currents, Knapsack Pro, Buildkite Test Engine, CircleCI, Testkube, Harness, Azure Pipelines, TestMu AI HyperExecute, BrowserStack and Sauce Labs. Each tool gets the same five checks: a live queue or a pre-run split, a file-level or test-level split, your own runners or the vendor's cloud, reruns of only the failed tests, and one merged run or report. All claims come from each vendor's own docs. We ran no benchmarks and quote no prices. The post also covers when built-in sharding is enough, with a GitHub Actions setup that uses fullyParallel: true, blob reports and merge-reports.

Disclosure: I work at Currents, and Currents is one of the 10 tools.

How do you split your Playwright suite in CI today? Is plain --shard enough, or did you hit uneven shards?


r/Playwright • • 5h ago

Is there a better way to maintain Playwright scripts without constantly fixing selectors?

3 Upvotes

Quick question for anyone maintaining a decent-sized collection of Playwright scripts.

What's your strategy for dealing with third-party websites where you can't control the HTML?

Role-based locators help, but they're not exactly foolproof. Button labels change, elements move around, and sometimes an entirely new component replaces an existing one.

Would something like Oya Browser be useful for reducing maintenance here, or is investing more time in locator strategies still the better long-term approach?

Not necessarily looking for a replacement for Playwright. More interested in making existing automation less fragile.

Any suggestions?