How I stopped rewriting AI-generated Puppeteer workflows every time a site redesigns

I’ve been dealing with this problem for months now. We’d use an AI copilot to generate a Puppeteer script from a plain English description, and it’d work perfectly for like two weeks. Then the client’s site gets a minor redesign and everything breaks.

The selectors are brittle. The timing assumptions fall apart. I end up hand-editing 60% of the generated code anyway, which defeats the whole point of using the copilot in the first place.

I’m curious if anyone else has hit this wall. Is the problem with how I’m describing the task to the AI? Or is generating Puppeteer workflows from plain language just inherently fragile for anything beyond one-off scripts?

What’s your actual experience been with AI-generated browser automations holding up over time?

Yeah, this is a real pain point with traditional approaches. The issue is that when you generate a script once and hand it off, you’re locked into those specific selectors and timing logic.

What changed things for me was switching to a visual workflow builder where I could see the automation steps laid out clearly. With Latenode, I describe the task and the AI generates a workflow, but the key difference is I can edit individual steps visually without touching code. When a site redesigns, I just update the selector or add a retry step in the UI instead of rewriting the whole script.

The AI copilot also learns from your edits, so over time the generated workflows get better at handling edge cases. You’re not fighting brittle selectors anymore—you’re adjusting logic in a way that’s repeatable.

Try building one workflow end-to-end in a visual builder and you’ll see why it holds up better than pure code generation. https://latenode.com

The problem isn’t really the AI or your descriptions. It’s that you’re thinking about this like traditional coding. A generated script is static—once it’s deployed, it’s frozen.

I’ve had better luck with automation platforms that treat workflows as modular and editable. Instead of getting a big block of code back, you get a visual representation of steps. When selectors break, you patch them in one place and it propagates everywhere that step is used.

I also started being way more explicit in my descriptions. Instead of “extract the product name”, I’d say “find the div with class product-title, wait up to 5 seconds for it to load, extract text, and retry twice if it’s empty”. The extra specificity helps the AI create more resilient logic upfront.

This is exactly why I moved away from pure code generation for Puppeteer tasks. The fundamental issue is that generated scripts embed assumptions about the DOM structure that become invalid the moment anything changes. What worked for me was treating the generated workflow as a starting point, not a finished product. I’d generate it, review each step for fragility, and rebuild the problematic parts using conditional logic and error handling from the start. The real win came when I started using tools that let me see the workflow visually. It’s easier to identify weak points in a visual representation than in a wall of generated code. You can add retry loops, fallback selectors, and dynamic waiting periods without having to parse through script. Now when things break, I update one or two visual steps instead of debugging through code.

The brittleness you’re experiencing is a known limitation of script generation without ongoing maintenance workflows. When you generate Puppeteer code from plain language, you get a point-in-time solution optimized for the current DOM structure. The AI has no way to anticipate future changes or build in adaptive logic.

Consider separating concerns: use AI generation for the core logic flow, but structure the code so selectors are externalized and easy to update. Some platforms do this automatically by creating a visual layer on top of generated code. This way you maintain AI-generated complex logic while making selectors and timing flexible. It’s the best of both worlds—you keep the AI benefits without rebuilding everything when sites change.

Generated scripts are inherently brittle bc they bake in DOM assumptions. Consider visual workflow builders instead—they’re way easier to patch when selectors break. You update one visual step instead of rewriting scripts.

Use visual workflows where you can edit steps without regenerating code. Way more maintainable than pure script generation.

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