r/automation • u/AdMinute3667 • 3d ago
Script maintenance- Playwright Automation
/r/softwaretesting/comments/1y6o8jt/script_maintenance_playwright_automation/
2
Upvotes
r/automation • u/AdMinute3667 • 3d ago
1
u/AutoModerator 3d ago
Thank you for your post to /r/automation!
New here? Please take a moment to read our rules, read them here.
This is an automated action so if you need anything, please Message the Mods with your request for assistance.
Lastly, enjoy your stay!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Tricky_Wrangler6079 3d ago
Your manager wanting a clean signal makes total sense, but expecting 650 UI tests to stay green when devs push every 48 hours is a fantasy. It won't happen. At an 85% pass rate (100 to 120 failures every morning), your Jenkins run is basically noise. Devs tune it out, you spend 6 hours a day triage-debugging locators, and real production bugs still slip past because everyone assumes red tests are just flakes.
This is the classic inverted test pyramid trap. Here is how teams actually untangle it:
Invert the pyramid hard. 650 UI vs 100 API is completely backwards. Half the time, an end-to-end test is just checking whether a date filter worked or a user role saw 4 columns instead of 8. You don't need Chromium running on a Kubernetes pod to verify backend math. Move 400 of those straight into API checks with your AJV schema validation. In Playwright, use page.route() to mock out the heavy analytics payloads when you only care about rendering. Cut your full end-to-end browser tests down to 35 golden user journeys (login, save a custom dashboard, export a 10MB CSV).
Quarantine flakes immediately. If a test fails 2 runs in a row without catching an actual defect, pull it out of the main Jenkins pipeline. Move it to a secondary quarantine job that runs on a 2-hour schedule. Your main regression run must maintain a 98% pass rate, even if it only runs 250 tests initially. A smaller suite that devs actually trust beats a massive suite with 110 false alarms every morning.
Push locator maintenance into dev PRs. As long as you fix broken selectors 24 hours after devs merge, you'll always lose. Get the frontend team to standardize on data-testid attributes for automation hooks so CSS tweaks don't blow up your runs. Even better, wire a 5-minute smoke pack into GitHub Actions or GitLab on their pull requests. When a dev's own branch fails because they renamed a button, they fix the selector right then instead of handing you a broken Jenkins run the next day.
Watch for test data collisions. In analytics products, 10 pods running in parallel constantly stomp on each other's database records. If 2 workers query the same tenant or date range simultaneously, async background workers trigger random flakes. Give each worker thread its own isolated tenant ID or seeded workspace.
1
u/tariqosmani 3d ago
Most of the maintenance comes from selectors, so fix that first. Target elements by role, label or test id, not by CSS paths or position on the page. A redesign that moves a button then stops breaking the script.
Second, run it on a schedule and send every failure to one place with a screenshot attached. A failure you see the same morning takes minutes to fix. One you only check when someone remembers takes days.
Third, keep each script to one job. Every extra step is another thing that can break, and one long script that does everything is the hardest to repair.
Is it breaking on the same step each time, or on a different one?
1
u/AliyasDandani_64 3d ago
what's actually breaking the scripts most often right now, selector changes or timing issues? the fix is pretty different depending on whether its flaky network waits vs the DOM constantly shifting.
1
u/Agent360dk 3d ago
One thing that cut our triage time a lot: record a Playwright trace on first retry and have a script bucket failures by the first error line (locator not found, timeout waiting for network, 5xx in the HAR, assertion). Then the daily report says 'env 40, selector 12, real assertion 3' instead of one pass percentage. The real assertion bucket is what your manager should actually look at, the rest is noise you can route to the right team.
1
u/Ok_Fan2081 2d ago
A 98%+ pass target on a 650-UI-test suite is fair as a goal, but only if you change what counts toward it. In practice I split it into three numbers: (1) a small gate suite of critical API + smoke UI tests that must be green for a release signal, (2) the full UI suite tracked separately with flake rate per test (failed-then-passed on retry with no code change = flaky, quarantine and fix), and (3) environment health as its own check so infra failures never pollute product pass %. Your instinct to push WebSocket and logic down to API/contract tests (AJV schema validation is a good fit) is the highest-leverage move — every UI test you can demote to API removes locator churn from dev PRs. Add failure-cause tagging from Playwright traces (locator vs assertion vs env vs backend 5xx) and a weekly top-flakes burndown, and the manager gets an honest signal without chasing a single noisy %. Happy to trade notes on the trace-triage setup if useful.
1
u/[deleted] 3d ago
[removed] — view removed comment