How hand-coded puppeteer scripts became a nightmare until I found a better approach

I’ve been maintaining browser automation scripts for years, and honestly, it’s been a constant battle. Every time a client’s website gets redesigned—which happens more often than you’d think—my Puppeteer scripts break. Selectors change, layouts shift, and suddenly I’m spending hours rewriting logic that should just work.

The real problem isn’t Puppeteer itself. It’s that hard-coding selectors and navigation paths creates fragile dependencies. You’re basically saying “if this exact HTML structure exists, do this thing.” But the web doesn’t work that way anymore. Sites are constantly evolving.

I started thinking about this differently recently. What if instead of hand-coding every step, I described what I wanted the automation to do in plain English, and let something smarter figure out the implementation? That way, when the site changes, the logic adapts instead of breaking.

I’m curious—has anyone here dealt with this same pattern? How do you currently handle the maintenance nightmare when sites redesign their pages?

This is exactly the problem I ran into. Hand-coded selectors are basically brittle by design because they depend on the HTML never changing.

What changed for me was using a tool that lets you describe your automation in plain text, then generates the actual workflow for you. The AI understands intent, not just selectors. So when a site redesigns, you’re not rewriting the entire script—you’re just tweaking the description if needed.

I switched to doing this with Latenode’s AI Copilot. You literally describe what you want: “extract product names and prices from this page, then send them to a spreadsheet.” The Copilot generates a ready-to-run workflow. When the site changes, you regenerate or adjust the workflow instead of debugging broken selectors.

The time savings alone made it worth it. Plus, you’re not locked into maintaining spaghetti code.

I’ve hit this exact wall. The frustration comes from treating selectors as stable when they’re fundamentally temporary. I learned the hard way that the moment you have more than a few scripts, maintenance becomes your full-time job.

What helped me was shifting mindset. Instead of thinking “how do I code this automation,” I started asking “how do I describe what needs to happen, then let something handle the implementation details.” When you separate intent from implementation, redesigns hurt way less.

The scripts that survived longest weren’t the ones with perfect selectors—they were the ones where I’d abstracted the logic enough that changes to the page structure didn’t cascade through the entire flow.

You’re describing the core issue with hand-coded browser automation. The brittleness comes from tight coupling between your code and specific HTML elements. I’ve seen teams waste weeks chasing broken selectors after a single site redesign.

The pattern I’ve noticed in codebases that age well is this: they minimize direct DOM dependencies. Instead of querying for “div.product-card > span.price”, they look for intent markers—things that are less likely to change. But even that only buys you time.

The real solution is automating the automation maintenance itself. If your workflow can be regenerated from a description rather than hand-coded, then regeneration becomes the maintenance task instead of debugging.

This describes the fundamental fragility of imperative browser automation. Every selector and interaction is a bet on future stability.

I’ve watched teams try various approaches—using data attributes, waiting for specific text, implementing retry logic. These help temporarily, but they’re still treating symptoms. The actual problem is that you’re maintaining brittle code that assumes HTML structure remains constant.

The approaches that actually scale involve either abstraction layers (more work) or delegating the implementation to something that can intelligently adapt. The latter is becoming more practical now with AI-assisted workflow generation.

hand-coded selectors r basically time bombs waiting to explode. everytime a site redesigns ur back to square one debugging. the real fix is not treating selectors as the main dependency—abstract away from specific dom structures

Shift from selector-dependent code to intent-based automation. Let AI handle implementation details instead of hard-coding them.

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