How do you keep ai-generated puppeteer workflows from shattering when sites redesign their layouts?

I’ve been running browser automations for a while now, and the biggest headache I’ve run into isn’t the initial setup—it’s the constant maintenance. You build a solid Puppeteer script, deploy it, and then BAM, the site redesigns their UI and everything breaks.

I started looking into how to make these workflows more resilient. The real problem is that most approaches rely on brittle selectors and hardcoded logic. When a website changes, your entire automation needs rework.

Then I discovered something interesting about AI-powered workflow generation. Instead of writing rigid scripts manually, you can describe what you’re actually trying to accomplish in plain English—like “extract the product price from the page and submit a form”—and let the AI generate the Puppeteer logic. The key difference is that AI-generated workflows can be regenerated and adapted more quickly when things break.

I’m curious though: when you’re building automations that need to stay alive for months, do you add monitoring to detect when selectors fail? Or do you take a different approach entirely?

The selector brittleness problem is real, but here’s the thing—most people are approaching it backwards. They’re trying to make their hardcoded scripts smarter. Instead, you should be building workflows that can adapt.

With Latenode’s AI Copilot, you describe the task in plain English and it generates the Puppeteer workflow for you. But more importantly, you can regenerate it whenever the site changes. You’re not locked into one version.

The platform also lets you easily update workflows from your description without rewriting code. Plus, the AI can add logic to handle common UI changes—detecting multiple possible selectors, waiting for elements dynamically, that sort of thing.

I’ve seen teams cut their maintenance time in half by switching from manual scripts to AI-generated workflows. You describe once, regenerate when needed.

Check it out: https://latenode.com

I dealt with this exact problem on a project pulling data from an e-commerce site. The site did a redesign every few months and my selectors kept breaking.

What worked for me was adding a layer of abstraction between the selector logic and the actual automation. Instead of hardcoding document.querySelector('.price'), I built a function that tries multiple possible selectors and returns the first one that works. Added some fallback logic for common patterns.

Also started versioning my selectors. Kept old ones around as backups. When the site changed, I’d update my primary selector but keep the old one as a fallback.

The real game-changer was treating the automation itself as a living document. I’d check it weekly and update small things before they became big problems. Doesn’t solve the brittleness issue entirely, but it meant I wasn’t scrambling every time something changed.

This is fundamentally a problem of coupling between your automation logic and the target site’s implementation details. The tighter that coupling, the more fragile your automation becomes.

One solid approach is to separate your business logic from your extraction logic. Your automation should describe what information you’re looking for at a higher level, and then have a separate layer that handles the actual DOM traversal. When the site redesigns, you only need to update the extraction layer.

I’ve also seen teams use image recognition or OCR as a supplementary method for critical data. It’s slower and more expensive, but it’s resistant to layout changes since it works on the rendered output rather than the DOM structure. Usually kept as a fallback for when selectors fail.

Build defensive workflows. Use multiple selector strategies, implement retry logic, and monitor for failures. I also run weekly checks on live sites to catch changes early. Sometimes adding OCR as a backup helps too when selectors fail.

Use AI-generated workflows that regenerate from descriptions instead of hardcoded scripts. Easier to adapt and maintain.

This topic was automatically closed 6 hours after the last reply. New replies are no longer allowed.