<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammad Usman</title>
    <description>The latest articles on DEV Community by Muhammad Usman (@muhammad_usman_sqa).</description>
    <link>https://dev.to/muhammad_usman_sqa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4264548%2F73d6a462-5370-4e48-aa61-b1993cf7cfd4.png</url>
      <title>DEV Community: Muhammad Usman</title>
      <link>https://dev.to/muhammad_usman_sqa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muhammad_usman_sqa"/>
    <language>en</language>
    <item>
      <title>When a Self-Healing Locator Should Say No</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Thu, 26 Nov 2026 13:40:05 +0000</pubDate>
      <link>https://dev.to/muhammad_usman_sqa/when-a-self-healing-locator-should-say-no-3ico</link>
      <guid>https://dev.to/muhammad_usman_sqa/when-a-self-healing-locator-should-say-no-3ico</guid>
      <description>&lt;h3&gt;
  
  
  Why AI “fixes” need guardrails, and how a deterministic healer refuses a wrong green test
&lt;/h3&gt;

&lt;p&gt;Every QA lead I know has lived this moment too.&lt;/p&gt;

&lt;p&gt;A locator is broken. The id was renamed, or someone typo’d &lt;code&gt;#quantiy&lt;/code&gt;. A teammate pastes a new selector from an AI chat. The test goes green. The pull request moves on.&lt;/p&gt;

&lt;p&gt;And we tell ourselves the test is healed.&lt;/p&gt;

&lt;p&gt;After 10+ years in Quality Assurance, I have learned that a wrong locator that passes is more dangerous than a red test you can still see. A failing test asks a question. A guessed heal answers a different one. You didn’t learn whether the new locator still points at the same element. You only learned that the next run passed.&lt;/p&gt;

&lt;p&gt;The last edition was about not naming a failure “flaky” too early. This one is about the next habit that hides the truth: letting a “fix” rewrite a locator without proving it.&lt;/p&gt;

&lt;h3&gt;
  
  
  An AI rewrite is a suggestion, not a proof
&lt;/h3&gt;

&lt;p&gt;I use AI tools every week. They are fast at proposing a &lt;code&gt;getByRole&lt;/code&gt; or a CSS selector. They are also confident when they should not be.&lt;/p&gt;

&lt;p&gt;A model can invent a locator that matches something else on the page: a nearby button with a similar name, a decoy heading, a link that looks like a button. If the only check is “did the test pass?”, a wrong heal looks like a success. That is how a test stops verifying the thing you thought it was verifying.&lt;/p&gt;

&lt;p&gt;This is why I do not want a healer that always says yes. I want one that will refuse, and tell me why.&lt;/p&gt;

&lt;h3&gt;
  
  
  A heal has to earn its keep
&lt;/h3&gt;

&lt;p&gt;A safe heal is not “find anything that makes the test green.” It has to clear a short list.&lt;/p&gt;

&lt;p&gt;The failure has to be a locator problem, from the error evidence, not from a hunch. An assertion that failed because the text was wrong, or because a resolved element was the wrong count, is an app problem. Healing will not fix it, and it should not try.&lt;/p&gt;

&lt;p&gt;The replacement has to still carry the original element’s identity. A candidate that only looks similar is not enough.&lt;/p&gt;

&lt;p&gt;The previously failing test has to pass on a re-run. If that re-run fails, the file should go back to what it was, byte for byte.&lt;/p&gt;

&lt;p&gt;And if the match is ambiguous, if the kind is wrong, if a &lt;code&gt;.first()&lt;/code&gt; or &lt;code&gt;.nth()&lt;/code&gt; was deleted, or if the failure is not a locator problem at all, the honest output is a refusal with a reason.&lt;/p&gt;

&lt;p&gt;The principle is simple. A wrong locator that passes today is worse than a red test you can see.&lt;/p&gt;

&lt;h3&gt;
  
  
  When it should say no
&lt;/h3&gt;

&lt;p&gt;A kind mismatch. The original selector said what kind of element it meant. &lt;code&gt;#register-button&lt;/code&gt; is a button. A &lt;code&gt;.fill()&lt;/code&gt; target is a text input. A candidate of a conflicting kind should be refused, however well the name matched:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;kind mismatch: expected button, candidate is link&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ambiguity. Nothing should be picked from a set of close matches. The refusal should name them:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;ambiguous on route /: several close matches (#contact-email, #backup-email), refusing to guess&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A deleted positional disambiguator. If a locator now matches three elements, a guessed &lt;code&gt;.first()&lt;/code&gt; might pass the re-run and silently change what the test checks. The tool should refuse, and tell you what distinguishes the matches, instead of inventing a position.&lt;/p&gt;

&lt;p&gt;And failures that are not locator problems. If the element resolved, and the assertion is what failed, healing the selector will not help:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;shows the done status — not a locator problem, healing won't fix this&lt;br&gt;
    Error: expect(locator).toHaveText(expected) failed&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That last case is easy to miss when you are staring at a red test and an AI chat is already offering a new locator.&lt;/p&gt;

&lt;h3&gt;
  
  
  This is slow to do by hand. That’s where a tool helps.
&lt;/h3&gt;

&lt;p&gt;Our QA team does this work on broken locators in Playwright, Cypress, and Selenium tests, written in JavaScript or TypeScript. The method is the same whether you do it yourself or with help: classify the failure from the evidence, probe the page the test actually failed on, propose a replacement only when the identity holds, re-run the previously failing test, and refuse when a guess would be required.&lt;/p&gt;

&lt;p&gt;That is why we built &lt;a href="https://github.com/sprintsynergyio/qa-core-heal" rel="noopener noreferrer"&gt;qa-core-heal&lt;/a&gt;, an open-source CLI on npm. It is not a model guessing at your selectors. There is no LLM and no API key. The engine is deterministic: same page, same broken locator, same replacement, every time.&lt;/p&gt;

&lt;p&gt;If you already have a failing Playwright spec, this is the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i -D qa-core-heal
npx qa-core-heal tests/login.spec.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Zero config. If everything already passes, it prints &lt;code&gt;All tests passing. Nothing to heal.&lt;/code&gt; and exits, with no scanning, no probing, and no browser.&lt;/p&gt;

&lt;p&gt;On a locator typo, the current README run looks like this. The broken id is &lt;code&gt;#quantiy&lt;/code&gt;. It climbs the heal ladder, starting with role and accessible name, and proposes a semantic locator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  tests/login.spec.ts:
    → broken: page.locator('#quantiy')
    ✓ healed to page.getByRole("textbox", {"name":"quantity"})  (level=role)

Proposed heals (1):

  tests/login.spec.ts:6
    - page.locator('#quantiy')
    + page.getByRole("textbox", {"name":"quantity"})

Apply 1 heal(s)? [y/N] y
▸ Verifying: re-running 1 previously failing test(s)
  ✓ re-run passed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It asks before it writes. &lt;code&gt;--dry-run&lt;/code&gt; never writes. It never commits. Applying approved diffs to your working tree is the maximum action. You review, you commit.&lt;/p&gt;

&lt;p&gt;The page comes from the Playwright trace, so a locator that breaks three clicks deep is probed on the page it actually failed on, not on the homepage. Only the previously failing tests are re-run to verify. Every applied heal lands in &lt;code&gt;.qa-core/heal-log.jsonl&lt;/code&gt; with a verified flag. A failed re-run reverts the file byte for byte.&lt;/p&gt;

&lt;p&gt;On the 16 public eval suites in the repo (168 locators, 104 of them deliberately broken), measured under Playwright 1.60, that discipline holds: 72 of 72 healable breaks were fixed and verified by a passing re-run, 32 of 32 unhealable breaks were refused instead of guessed, 10 of 10 intact locators were left untouched, no valid locator was wrongly rewritten, and no heal pointed at the wrong element. Two full runs produced byte-identical results. That is a pinned suite in the repo, not a promise about every app you will ever point it at. You can run the same harness with &lt;code&gt;npm run evals&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It also has limits I will not hide. A heal is correct against today’s page; a later redesign can invalidate it, which is why the default is to re-verify on every run. It cannot see silent positional drift: if a list reorders, &lt;code&gt;li:nth-child(2)&lt;/code&gt; still resolves, to a different row, and is reported intact. Hash-suffixed generated ids heal only when the element offers a second identity. And it will not heal a state-dependent element from a static scan of the page as it first loads. The run-first default closes most of the URL side of that gap, because it probes the page the test actually failed on.&lt;/p&gt;

&lt;h3&gt;
  
  
  What still needs human judgment
&lt;/h3&gt;

&lt;p&gt;A tool can classify the error, walk the heal ladder, and refuse a guess. It cannot own the release.&lt;/p&gt;

&lt;p&gt;Someone still has to read the diff and decide whether the new locator is the contract you want. Someone still has to decide whether the element was renamed, or whether the button is genuinely gone. Someone still has to say whether the change is safe to commit.&lt;/p&gt;

&lt;p&gt;A verified heal is still a change to what the test targets. Treat it like any other patch.&lt;/p&gt;

&lt;p&gt;That is the same point I keep coming back to in this newsletter. Tools can scale the mechanical work. Quality remains a human responsibility.&lt;/p&gt;

&lt;h3&gt;
  
  
  The takeaway
&lt;/h3&gt;

&lt;p&gt;The next time a locator breaks, resist the urge to paste the first AI suggestion and ship it.&lt;/p&gt;

&lt;p&gt;Read the error. Ask whether this is even a locator failure. If a replacement is offered, ask whether it still carries the original element’s identity, and whether the previously failing test passed on a re-run. If the match is messy, say no, and keep the red test visible.&lt;/p&gt;

&lt;p&gt;If you want help doing that on a real spec, try qa-core-heal. It is free, open source, and it will refuse when a guess would be required:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sprintsynergyio/qa-core-heal" rel="noopener noreferrer"&gt;github.com/sprintsynergyio/qa-core-heal&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/qa-core-heal" rel="noopener noreferrer"&gt;npmjs.com/package/qa-core-heal&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SprintSynergy is an AI-based QA automation company: AI testing agents plus our QA team. We use tools like this so our QA team can spend less time guessing at broken locators, and more time judging the risk.&lt;/p&gt;

&lt;p&gt;When did a “fixed” locator last pass for your team while pointing at the wrong element?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>testing</category>
      <category>playwright</category>
      <category>automation</category>
    </item>
    <item>
      <title>A Flaky Test or a Real Bug? Start With the Evidence</title>
      <dc:creator>Muhammad Usman</dc:creator>
      <pubDate>Wed, 25 Nov 2026 11:03:42 +0000</pubDate>
      <link>https://dev.to/muhammad_usman_sqa/a-flaky-test-or-a-real-bug-start-with-the-evidence-16h8</link>
      <guid>https://dev.to/muhammad_usman_sqa/a-flaky-test-or-a-real-bug-start-with-the-evidence-16h8</guid>
      <description>&lt;h3&gt;
  
  
  How to triage Playwright failures without guessing, rerunning blindly, or loosening the assertion
&lt;/h3&gt;

&lt;p&gt;Every QA lead I know has lived this moment.&lt;/p&gt;

&lt;p&gt;CI goes red. Someone says, “It’s probably flaky.” Someone hits rerun. The job goes green. The pull request moves on.&lt;/p&gt;

&lt;p&gt;And we tell ourselves we handled it.&lt;/p&gt;

&lt;p&gt;After 10+ years in Quality Assurance, I have learned that this habit is more dangerous than a failing test. A red build asks a question. A blind rerun answers a different one. You didn’t learn whether the product broke, whether the test is unstable, or whether the environment hiccupped. You only learned that the next attempt passed.&lt;/p&gt;

&lt;p&gt;In January I wrote that I have seen teams spend more time fixing tests than finding defects, and delay a release not because of a bug, but because the automation itself was broken. Flaky Playwright tests are often how that starts.&lt;/p&gt;

&lt;p&gt;So this edition is practical. Not another argument about automation. A way to triage a failure before you decide what it is.&lt;/p&gt;

&lt;h3&gt;
  
  
  The mistake is naming it too early
&lt;/h3&gt;

&lt;p&gt;“Flaky” is a verdict. It is not a starting point.&lt;/p&gt;

&lt;p&gt;A test that failed once and passed once might be unstable. It might also be a real defect that only appears under load, a race in the app, shared test data, or a network drop. If you label it flaky too early, you stop looking.&lt;/p&gt;

&lt;p&gt;A useful first question is not “should we rerun it?” It is this:&lt;/p&gt;

&lt;p&gt;Did this test pass and fail on the same code?&lt;/p&gt;

&lt;p&gt;If it failed on every attempt, and the error is the same, you may be looking at a likely real bug, a broken locator, or an environment issue. If you only have one failed attempt, you do not have a diagnosis yet. You need more runs.&lt;/p&gt;

&lt;p&gt;The second question is: what does the error actually say?&lt;/p&gt;

&lt;p&gt;Not the summary line. The words in the log.&lt;/p&gt;

&lt;h3&gt;
  
  
  Read the evidence, then put it in a bucket
&lt;/h3&gt;

&lt;p&gt;When I sit with a Playwright failure, I try to put it into one of a few buckets, using the error text, not a hunch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Selectors.&lt;/strong&gt; The locator never found the element, found zero elements, or hit a strict mode violation. A typo in a role name lives here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Timing.&lt;/strong&gt; The test ran out of time, a wait was too short, or the page was still loading. A locator that did resolve, but the element was still hidden, is often timing, not a missing selector.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment.&lt;/strong&gt; A disconnected network, a connection refused, a 5xx from the server. Infrastructure, not the assertion.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test data.&lt;/strong&gt; The record already existed, the fixture was dirty, or two tests shared state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unknown, for now.&lt;/strong&gt; The expected value and the received value don’t match, and the error doesn’t point to a locator or a timeout. That can still be a real product bug. It can also be a bad assumption in the test.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two rules save a lot of pain.&lt;/p&gt;

&lt;p&gt;Don’t loosen the assertion just to make the test pass. If the page said “Ready” and the test expected a different heading, the interesting work is to decide which one is wrong.&lt;/p&gt;

&lt;p&gt;And don’t hide the first failure behind retries. Playwright retries are useful, but a retry that turns a fail into a pass can bury the original error. If you collect more attempts, keep that first failure visible.&lt;/p&gt;

&lt;p&gt;Prefer a Playwright JSON report when you can. It keeps every retry attempt. A default JUnit report usually does not.&lt;/p&gt;

&lt;h3&gt;
  
  
  This is slow to do by hand. That’s where a tool helps.
&lt;/h3&gt;

&lt;p&gt;Our QA team does this work on Playwright reports. The method is the same whether you do it yourself or with help: parse every attempt the report contains, quote the evidence, name a likely cause, and only then suggest a next step.&lt;/p&gt;

&lt;p&gt;That is why we built &lt;a href="https://github.com/sprintsynergyio/qa-core-flaky" rel="noopener noreferrer"&gt;qa-core-flaky&lt;/a&gt;, an open-source CLI on npm. It is not a model guessing at your tests. The likely causes are deterministic rules. The verdict engine does not call a model. It reads a Playwright JSON report or a JUnit XML report and writes a triage report you can share.&lt;/p&gt;

&lt;p&gt;If you already have a JSON report from Playwright, this is the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i -D qa-core-flaky
npx qa-core-flaky triage &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;report.json&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; --out-dir out --html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It writes &lt;code&gt;triage.json&lt;/code&gt;, &lt;code&gt;triage.md&lt;/code&gt;, and a self-contained HTML report. Passed tests are not listed. Home usernames and token-like strings are hidden by default, so the HTML file is the one I would send to a colleague.&lt;/p&gt;

&lt;p&gt;I ran the published package, version 0.1.2, against its own Playwright fixture report. Three failures came back as three different verdicts.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;always fails&lt;/code&gt; was a &lt;strong&gt;likely real bug&lt;/strong&gt;, with medium confidence. Every attempt failed with the same signature. The evidence was plain:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Expected: "a different heading"&lt;br&gt;
Received: "Ready"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The suggested fix was to compare those values with what the user sees, and not loosen the assertion. “Likely” is the right word. The report does not say the bug is confirmed, and neither should we.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;flaky by retry&lt;/code&gt; was &lt;strong&gt;flaky&lt;/strong&gt;, with low confidence, because there were only two attempts: one pass and one fail on the same code. The report also added a sentence I agree with: “A flaky test can still point to a real app defect. Check the app behavior too.”&lt;/p&gt;

&lt;p&gt;&lt;code&gt;times out&lt;/code&gt; was &lt;strong&gt;needs more runs&lt;/strong&gt;. The locator &lt;code&gt;getByRole('button', { name: 'Never Appears' })&lt;/code&gt; never resolved, and the test timed out at 1000ms. That is a signal, not a final verdict. The next step is more attempts, with the first failure still visible.&lt;/p&gt;

&lt;p&gt;On a recorded run against the public SauceDemo practice app, the same kind of report is easier to show a team. One test, “login page loads after a network drop,” was marked flaky with high confidence. The evidence was a single line:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Error: page.goto: net::ERR_INTERNET_DISCONNECTED at &lt;a href="https://www.saucedemo.com/" rel="noopener noreferrer"&gt;https://www.saucedemo.com/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The suggested fix was to check the network and the base URL, and to keep retries only for infrastructure errors. That is a very different conversation from “the login test is flaky.”&lt;/p&gt;

&lt;p&gt;If you want more attempts, &lt;code&gt;rerun&lt;/code&gt; will collect them. It defaults to &lt;code&gt;--retries 0&lt;/code&gt;, so a retry inside the rerun cannot hide the first failure.&lt;/p&gt;

&lt;h3&gt;
  
  
  What still needs human judgment
&lt;/h3&gt;

&lt;p&gt;A tool can quote the error and apply a decision table. It cannot own the release.&lt;/p&gt;

&lt;p&gt;Someone still has to decide whether the locator is wrong or the button is genuinely missing. Someone still has to decide whether to fix the test, fix the app, or fix the environment. Someone still has to say whether the build is safe to ship.&lt;/p&gt;

&lt;p&gt;A flaky verdict can still be an app defect that only appears sometimes. Shared state, a race in the UI, a slow API: those are product problems that show up as unstable tests.&lt;/p&gt;

&lt;p&gt;That is the same point I keep coming back to in this newsletter. Tools can scale the mechanical work. Quality remains a human responsibility.&lt;/p&gt;

&lt;h3&gt;
  
  
  The takeaway
&lt;/h3&gt;

&lt;p&gt;The next time a Playwright test fails, resist the urge to start with a rerun.&lt;/p&gt;

&lt;p&gt;Open the report. Look at every attempt. Ask whether a pass and a fail share the same code. Quote the error. Put it in a bucket. If you only have one failure, say so, and collect more evidence without burying the first one.&lt;/p&gt;

&lt;p&gt;If you want help doing that on a real report, try qa-core-flaky. It is free, open source, and takes a JSON or JUnit file you already have:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sprintsynergyio/qa-core-flaky" rel="noopener noreferrer"&gt;github.com/sprintsynergyio/qa-core-flaky&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/qa-core-flaky" rel="noopener noreferrer"&gt;npmjs.com/package/qa-core-flaky&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SprintSynergy is an AI-based QA automation company: AI testing agents plus our QA team. We use tools like this so our QA team can spend less time guessing at red builds, and more time judging the risk.&lt;/p&gt;

&lt;p&gt;What’s the last failure your team reran without reading the error?&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>ai</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
