{"_id":"@axeforging/playwright-smart-locators","_rev":"7-610eb010019eee393562acb3e05bffde","name":"@axeforging/playwright-smart-locators","dist-tags":{"latest":"1.0.6"},"versions":{"1.0.1":{"name":"@axeforging/playwright-smart-locators","version":"1.0.1","keywords":["playwright","self-healing","auto-healing","ai","llm","e2e","testing","test-automation","locators","css-selectors","dom-caching","page-object-model","pom","ollama","openai","anthropic","flaky-tests","qa"],"author":{"name":"QA Architecture Team"},"license":"ISC","_id":"@axeforging/playwright-smart-locators@1.0.1","maintainers":[{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"}],"homepage":"https://github.com/your-username/ai-healer#readme","bugs":{"url":"https://github.com/your-username/ai-healer/issues"},"dist":{"shasum":"6cd04e5e23044f45eb9abc268b0993e1794dab58","tarball":"https://registry.npmjs.org/@axeforging/playwright-smart-locators/-/playwright-smart-locators-1.0.1.tgz","fileCount":6,"integrity":"sha512-pSNcbs9rrNoW9of9LBwP+PnV4qK+5ZT6ftp+0oGqzwAXQCZDgpqg389N5kanKxkUvD3Y+TFovLJGyor6OaDt1g==","signatures":[{"sig":"MEYCIQDPxVPYeBrcnvf6qwxpWkPppOZF7X1G9n3FAGrrlAAWVgIhAP3YsUifAJAzxFb39V9KwiJLqokxLcGZjLj+monsjSWN","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32357},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./dist/reporter":{"default":"./dist/reporter.js"}},"gitHead":"34814b9dfeab468e65fa6ac481b98b77617e7496","scripts":{"test":"npx playwright test","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},"repository":{"url":"git+https://github.com/your-username/ai-healer.git","type":"git"},"_npmVersion":"10.8.2","description":"AI-powered self-healing smart web locators for Playwright tests.","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^20.0.0","@playwright/test":"^1.40.0"},"peerDependencies":{"@playwright/test":">=1.30.0"},"_npmOperationalInternal":{"tmp":"tmp/playwright-smart-locators_1.0.1_1772226983006_0.942685948953552","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@axeforging/playwright-smart-locators","version":"1.0.2","keywords":["playwright","self-healing","auto-healing","ai","llm","e2e","testing","test-automation","locators","css-selectors","dom-caching","page-object-model","pom","ollama","openai","anthropic","flaky-tests","qa"],"author":{"name":"QA Architecture Team"},"license":"ISC","_id":"@axeforging/playwright-smart-locators@1.0.2","maintainers":[{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"}],"homepage":"https://github.com/your-username/ai-healer#readme","bugs":{"url":"https://github.com/your-username/ai-healer/issues"},"dist":{"shasum":"70a8dc957fa802dcc28ea025a4353f8e2ba61afb","tarball":"https://registry.npmjs.org/@axeforging/playwright-smart-locators/-/playwright-smart-locators-1.0.2.tgz","fileCount":6,"integrity":"sha512-+yS+Kq6icuoLycSOmSTDhNIr8slgRyEUnGVpPEYQscAkRYHFnqmqHTT9hPVMlLK7Vnq1L47NZTb2QUyToRJ+Xg==","signatures":[{"sig":"MEUCIQCg/An5Lv9f4IJgwQXO2eav0Ck4SPrvnmh87bqSZTfnyQIgdzO65HuhsqMFvo8w3K4y5uWU/KiWykU6rqvAxXSMyJc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32340},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./dist/reporter":{"default":"./dist/reporter.js"}},"gitHead":"bcd96e1b3d9a8dc7323bd94ba6b47cefeb3cdc76","scripts":{"test":"npx playwright test","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},"repository":{"url":"git+https://github.com/your-username/ai-healer.git","type":"git"},"_npmVersion":"10.8.2","description":"AI-powered self-healing smart web locators for Playwright tests.","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^20.0.0","@playwright/test":"^1.40.0"},"peerDependencies":{"@playwright/test":">=1.30.0"},"_npmOperationalInternal":{"tmp":"tmp/playwright-smart-locators_1.0.2_1772375204609_0.9805461485647036","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@axeforging/playwright-smart-locators","version":"1.0.3","keywords":["playwright","self-healing","auto-healing","ai","llm","e2e","testing","test-automation","locators","css-selectors","dom-caching","page-object-model","pom","ollama","openai","anthropic","flaky-tests","qa"],"author":{"name":"R&D Team"},"license":"MIT","_id":"@axeforging/playwright-smart-locators@1.0.3","maintainers":[{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},{"name":"theyoungestaxe","email":"lucas.dpmachado@gmail.com"}],"homepage":"https://github.com/AxeForging/playwright-smart-locators","bugs":{"url":"https://github.com/AxeForging/playwright-smart-locators/issues"},"dist":{"shasum":"1613d48e697b63a0c71b48202f19f2b89005bf7a","tarball":"https://registry.npmjs.org/@axeforging/playwright-smart-locators/-/playwright-smart-locators-1.0.3.tgz","fileCount":6,"integrity":"sha512-mLvWLLKoKjpSJc/1jjyLpagyzDnRWUzsRNPN+qJAceiAiSgHgABbmZMyFqysy9FcHhI9PJ9TQ0j/nJOxI4rnmA==","signatures":[{"sig":"MEUCICpw2ENYRZ0Pb79a11C5sKAhjWZSSA/DV2NxzrTD8cRmAiEA4TbfXQW23JkHxOa6uSdWQdPNX5xvaF0vg5RhVZDJFes=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32356},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./dist/reporter":{"default":"./dist/reporter.js"}},"gitHead":"466490837799cf36a3feca575fed097c69920b08","scripts":{"test":"npx playwright test","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},"repository":{"url":"git+https://github.com/AxeForging/playwright-smart-locators.git","type":"git"},"_npmVersion":"10.8.2","description":"AI-powered self-healing smart web locators for Playwright tests.","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^20.0.0","@playwright/test":"^1.40.0"},"peerDependencies":{"@playwright/test":">=1.30.0"},"_npmOperationalInternal":{"tmp":"tmp/playwright-smart-locators_1.0.3_1772642354386_0.45334634889231107","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@axeforging/playwright-smart-locators","version":"1.0.4","keywords":["playwright","self-healing","auto-healing","ai","llm","e2e","testing","test-automation","locators","css-selectors","dom-caching","page-object-model","pom","ollama","openai","anthropic","flaky-tests","qa"],"author":{"name":"R&D Team"},"license":"MIT","_id":"@axeforging/playwright-smart-locators@1.0.4","maintainers":[{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},{"name":"theyoungestaxe","email":"lucas.dpmachado@gmail.com"}],"homepage":"https://github.com/AxeForging/playwright-smart-locators","bugs":{"url":"https://github.com/AxeForging/playwright-smart-locators/issues"},"dist":{"shasum":"20b038d5abeea2998385a19e26b3df3748138e4e","tarball":"https://registry.npmjs.org/@axeforging/playwright-smart-locators/-/playwright-smart-locators-1.0.4.tgz","fileCount":6,"integrity":"sha512-ldPWODV/2TF2Cghva8RV8yWHV7eyv+vXH0Q58tjEFRrWpRDZqzNWI4u8iEbh6h25e4EHivsyYM4z0LtLySZn0A==","signatures":[{"sig":"MEQCIF1PvQh4UqrjMYM1KMnRkUa15VdK/fzkYRFN9zhVw/9lAiB16GkV4uR9MNKFAS6Tr1uRooqnCL8alFSAtuzzG5NGsA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33511},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./dist/reporter":{"default":"./dist/reporter.js"}},"gitHead":"cb27c206a94625bcd1400c1a0506639800036b28","scripts":{"test":"npx playwright test","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},"repository":{"url":"git+https://github.com/AxeForging/playwright-smart-locators.git","type":"git"},"_npmVersion":"10.8.2","description":"AI-powered self-healing smart web locators for Playwright tests.","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^20.0.0","@playwright/test":"^1.40.0"},"peerDependencies":{"@playwright/test":">=1.30.0"},"_npmOperationalInternal":{"tmp":"tmp/playwright-smart-locators_1.0.4_1772649905016_0.3370561049664318","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@axeforging/playwright-smart-locators","version":"1.0.5","keywords":["playwright","self-healing","auto-healing","ai","llm","e2e","testing","test-automation","locators","css-selectors","dom-caching","page-object-model","pom","ollama","openai","anthropic","flaky-tests","qa"],"author":{"name":"R&D Team"},"license":"MIT","_id":"@axeforging/playwright-smart-locators@1.0.5","maintainers":[{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},{"name":"theyoungestaxe","email":"lucas.dpmachado@gmail.com"}],"homepage":"https://github.com/AxeForging/playwright-smart-locators","bugs":{"url":"https://github.com/AxeForging/playwright-smart-locators/issues"},"dist":{"shasum":"fd42e1bde1aa296237179027736ed805f419f68c","tarball":"https://registry.npmjs.org/@axeforging/playwright-smart-locators/-/playwright-smart-locators-1.0.5.tgz","fileCount":14,"integrity":"sha512-ZSWo2GS0GyWEtHyiC3UEIeFRNG2qe9MozDOu2Raph7KWucojkNz6vgSBg5OWXcr04PwciuDSeEHGIVbpUCoaXg==","signatures":[{"sig":"MEYCIQDgK52YFSmTEZgx57V9sVgunApm2IR2kLFNkqcZ3Yw+OgIhAKfjPWvcqR+CCd3yBE2Y6QP5Pk9tBGc8hUc48EY11t9e","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35921},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./dist/reporter":{"default":"./dist/reporter.js"}},"gitHead":"27fde290e587f29310dadfd096b29f107c91dca7","scripts":{"test":"npx playwright test","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},"repository":{"url":"git+https://github.com/AxeForging/playwright-smart-locators.git","type":"git"},"_npmVersion":"10.8.2","description":"AI-powered self-healing smart web locators for Playwright tests.","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0","@types/node":"^20.0.0","@playwright/test":"^1.40.0"},"peerDependencies":{"@playwright/test":">=1.30.0"},"_npmOperationalInternal":{"tmp":"tmp/playwright-smart-locators_1.0.5_1772660977955_0.29058720966446105","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@axeforging/playwright-smart-locators","version":"1.0.6","description":"AI-powered self-healing smart web locators for Playwright tests.","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./dist/reporter":{"default":"./dist/reporter.js"}},"scripts":{"build":"tsc","prepare":"npm run build","test":"npx playwright test"},"keywords":["playwright","self-healing","auto-healing","ai","llm","e2e","testing","test-automation","locators","css-selectors","dom-caching","page-object-model","pom","ollama","openai","anthropic","flaky-tests","qa"],"peerDependencies":{"@playwright/test":">=1.30.0"},"devDependencies":{"@playwright/test":"^1.40.0","@types/node":"^20.0.0","typescript":"^5.0.0"},"engines":{"node":">=18.0.0"},"repository":{"type":"git","url":"git+https://github.com/AxeForging/playwright-smart-locators.git"},"bugs":{"url":"https://github.com/AxeForging/playwright-smart-locators/issues"},"homepage":"https://github.com/AxeForging/playwright-smart-locators","author":{"name":"R&D Team"},"license":"MIT","_id":"@axeforging/playwright-smart-locators@1.0.6","gitHead":"8769135a1073d6812d70a7e71e50ac9452019731","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-c3pRfQ8v3DGNBFLn1cwneAHprs+WW87IHgq+ExHnK9beNbNpr9sMNQhPwzZdVe1Xu0zlsKkuLkTYQrNTvQMiqQ==","shasum":"2310dacc3ad63c562939e934c265d2cf9e736828","tarball":"https://registry.npmjs.org/@axeforging/playwright-smart-locators/-/playwright-smart-locators-1.0.6.tgz","fileCount":14,"unpackedSize":33956,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICaeZvT0wXc+ZTx1qTY8u3kaTNRSVPV/wJeIs054GDCPAiBSbGTu4+BiqwbXRTWIRuE4Aym3niW2vxYYRPX5+GrwJw=="}]},"_npmUser":{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},"directories":{},"maintainers":[{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},{"name":"theyoungestaxe","email":"lucas.dpmachado@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/playwright-smart-locators_1.0.6_1772662626017_0.3196615529681579"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-27T21:16:22.896Z","modified":"2026-03-04T22:17:06.321Z","1.0.1":"2026-02-27T21:16:23.136Z","1.0.2":"2026-03-01T14:26:44.795Z","1.0.3":"2026-03-04T16:39:14.527Z","1.0.4":"2026-03-04T18:45:05.189Z","1.0.5":"2026-03-04T21:49:38.108Z","1.0.6":"2026-03-04T22:17:06.163Z"},"bugs":{"url":"https://github.com/AxeForging/playwright-smart-locators/issues"},"author":{"name":"R&D Team"},"license":"MIT","homepage":"https://github.com/AxeForging/playwright-smart-locators","keywords":["playwright","self-healing","auto-healing","ai","llm","e2e","testing","test-automation","locators","css-selectors","dom-caching","page-object-model","pom","ollama","openai","anthropic","flaky-tests","qa"],"repository":{"type":"git","url":"git+https://github.com/AxeForging/playwright-smart-locators.git"},"description":"AI-powered self-healing smart web locators for Playwright tests.","maintainers":[{"name":"murilo.paula.machado","email":"murilo.paula.machado@gmail.com"},{"name":"theyoungestaxe","email":"lucas.dpmachado@gmail.com"}],"readme":"# playwright-smart-locators\n\n[![NPM Version](https://img.shields.io/npm/v/@axeforging/playwright-smart-locators.svg?style=flat-square)](https://www.npmjs.com/package/@axeforging/playwright-smart-locators)\n[![NPM Weekly Downloads](https://img.shields.io/npm/dw/@axeforging/playwright-smart-locators.svg?style=flat-square)](https://www.npmjs.com/package/@axeforging/playwright-smart-locators)\n[![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/@axeforging/playwright-smart-locators.svg?style=flat-square)](https://www.npmjs.com/package/@axeforging/playwright-smart-locators)\n\n**AI-powered developer tool for diagnosing and fixing broken Playwright locators during local development.**\n\n`playwright-smart-locators` helps developers quickly diagnose and fix broken CSS selectors in End-to-End (E2E) test scripts during local development. When a locator fails, it intercepts Playwright's `TimeoutError`, evaluates the broken selector against live and cached DOMs, and uses an AI LLM to suggest a corrected locator. It then generates a `-healed.ts` suggestion file for you to review and adopt into your codebase.\n\nWe extensively tested with local 7B models (e.g., **Qwen 2.5 Coder 7B** via Ollama and Open WebUI) to provide robust healing suggestions without significant API costs.\n\n---\n\n## 🔒 Data Privacy & Enterprise Security\n\nFor confidential environments or strict data privacy, **exclusively use a local Ollama endpoint** (e.g., `qwen2.5:7b` via local Open WebUI). This prevents DOM data, proprietary class names, or sensitive layouts from leaving your secure network. Cloud providers (OpenAI/Anthropic) are suitable only if testing environments are public or data exfiltration is not a concern.\n\n---\n\n## ✨ Features\n\n*   **Seamless Proxy Interceptor**: Transparently wraps Playwright, catching native timeouts without test logic modification.\n*   **Proactive DOM Caching**: Records \"Known Good\" DOM snapshots before successful actions. When an element breaks, the AI compares historical and current DOMs to identify altered properties.\n*   **Healed Suggestion File**: Generates a `*.spec-healed.ts` file with suggested locator fixes alongside your original spec file for you to review and adopt.\n*   **Healed Suggestion File**: Generates a `*.spec-healed.ts` file with suggested locator fixes alongside your original spec file for you to review and adopt.\n*   **Page Object Model (POM) Parsing**: Dynamically parses the JavaScript execution stack. If a locator fails in a POM class (e.g., `login.page.ts`), the AI Healer traces the boundary and rewrites the POM file natively.\n*   **Top-7 Fallback Engine**: The AI returns the top 7 most confident locators, prioritized by confidence. The Healer executes these sequentially, allowing smaller models multiple attempts without test suite failure.\n*   **Syntactical Sanitization**: A heuristic regex scrubber automatically corrects SASS-like pseudo-class hallucinations (e.g., `tag(class1 class2)` to `tag.class1.class2`) common with quantized local models. Includes a case-insensitive CSS fallback that retries selectors in lowercase when the original casing fails.\n*   **Spec Rewrite Proposals**: Creates an updated `spec-healed.ts` file with proposed locator replacements. Review the suggestions and copy them into your spec files to permanently fix your tests.\n\n---\n\n## 🛠 Usage\n\n### 1. Install the package:\n\n```bash\nnpm install -D @axeforging/playwright-smart-locators\n```\n\n### 2. Wrap your `playwright.config.ts`:\n\nImport the custom auto-healer and configure your Open WebUI or OpenAI-compatible endpoint:\n\n```typescript\nimport { defineConfig, devices } from '@playwright/test';\n\nexport default defineConfig({\n    reporter: [\n        ['html'],\n        ['@axeforging/playwright-smart-locators/dist/reporter'] // Required for Auto-Spec Rewriting\n    ],\n    use: {\n        enableAutoHeal: !process.env.CI, // Enable in local dev, disable in CI/CD\n        enableAutoHeal: !process.env.CI, // Enable in local dev, disable in CI/CD\n        aiModel: 'qwen2.5:7b', // Local Ollama model for maximum privacy\n        aiPipeUrl: process.env.AI_API_URL, // e.g., Open WebUI, OpenAI, or Anthropic endpoint\n        aiAdminKey: process.env.AI_API_KEY, // e.g., 'sk-...'\n        aiProvider: 'openai' // 'openai' (default) or 'anthropic'\n    }\n});\n```\n\n### 3. Import `test` from the library:\n\nReplace standard Playwright `@playwright/test` imports in your spec files:\n\n```diff\n- import { test, expect } from '@playwright/test';\n+ import { test, expect } from '@axeforging/playwright-smart-locators';\n```\n\n---\n\n## 🛠 Example Project\n\nThe repository includes an `example` testing suite demonstrating Auto-Healer capabilities. These tests target [github.com/axeforging/tacomex-8bit-shop](https://github.com/AxeForging/tacomex-8bit-shop).\n\nTo run the examples:\n\n1.  Navigate to the example directory: `cd example`\n2.  Install dependencies: `npm install`\n3.  Run the tests: `npx playwright test`\n\n### Example Scenarios\n\nThe example includes 6 intentionally broken tests that the AI will auto-heal at runtime:\n\n*   **`tests/example.spec.ts`**: 3 standard procedural Playwright tests.\n*   **`tests/pom.spec.ts`**: 3 tests using Page Object Model (POM), demonstrating how the Healer rewrites `pages/login.page.ts` natively.\n\n---\n\n## 🚀 Execution Example (Local Development)\n\nDuring local development, `playwright-smart-locators` provides real-time console feedback on the healing process, detailing actions taken and summarizing generated suggestion files:\n\n```plaintext\nRunning 6 tests using 6 workers\n\n🤖 [AI Auto-Heal] Intercepted failure on: locator('text=\"Sign In\"')\n✅ [AI Auto-Heal] Fixed! Resuming with: .navbar__login-btn\n  ✓  2 tests/pom.spec.ts:11:9 › POM Auto-Healing Scenarios › Scenario 1: Text changed (POM Login Button) (5.0s)\n\n...\n\n  6 passed (7.7s)\n\n=========================================\n🧠 Smart Locators Summary\n=========================================\nTotal Locators Healed: 6\n✨ Generated auto-healed spec: /your-project/example/pages/login.page-healed.ts\n✨ Generated auto-healed spec: /your-project/example/tests/example.spec-healed.ts\n```\n\nReview the generated `-healed.ts` files, verify the suggested locators are correct, and adopt them into your spec files.\n\n---\n\n## 🧠 The \"Line of Thought\" Lifecycle\n\n```mermaid\nsequenceDiagram\n    participant Test as Playwright Suite\n    participant Proxy as Smart Proxy\n    participant Cache as DOM Cache\n    participant LLM as AI (Local/Cloud)\n    participant Disk as File System\n\n    Note over Test, Disk: 🟢 Record Phase (Green Test)\n    Test->>Proxy: Successful locator action\n    Proxy->>Cache: Save \"Known Good\" DOM snapshot\n\n    Note over Test, Disk: 🔴 Intercept Phase (Broken Test)\n    Test->>Proxy: Execute locator (element changed/missing)\n    Proxy--xTest: Intercept TimeoutError\n    \n    Note over Proxy, LLM: 🧠 Contextual Evaluation & Resolution\n    Proxy->>Cache: Retrieve cached \"Known Good\" DOM\n    Proxy->>LLM: Transmit Payload (Broken Locator + Cached DOM + Current DOM)\n    LLM-->>Proxy: Return Top 7 Resilient Locators (Priority Ranked)\n    \n    Note over Test, Disk: ✨ Execution & Rewrite\n    Proxy->>Test: Try healed locator & continue test run\n    Proxy->>Disk: Generate *.spec-healed.ts suggestion file for review\n    Proxy->>Test: Try healed locator & continue test run\n    Proxy->>Disk: Generate *.spec-healed.ts suggestion file for review\n```\n\n1.  **Record Phase**: During a successful test run, the library caches a stripped \"Known Good\" DOM snapshot locally (e.g., `.smart-locators-cache.json`) before successful locator actions.\n2.  **Intercept Phase**: If an element changes (e.g., `<button class=\"btn-primary\">` to `<button class=\"btn-accent\">`), the proxy intercepts Playwright's `TimeoutError`.\n3.  **Contextual Evaluation**: The proxy sends a payload to the LLM with the **Broken Locator**, **Known Good DOM**, and **Current Broken DOM**.\n4.  **Resolution**: The LLM evaluates DOM differences to identify the element and calculates the most resilient new CSS selector based on a strict priority hierarchy.\n5.  **Execution & Suggestion**: The library tries the healed locator to continue your test session, and the reporter generates a `-healed.ts` suggestion file for you to review before adopting the fix.\n5.  **Execution & Suggestion**: The library tries the healed locator to continue your test session, and the reporter generates a `-healed.ts` suggestion file for you to review before adopting the fix.\n\n---\n\n## 🧪 Model Experiments & Insights\n\nOur goal was a model providing 100% syntactical CSS accuracy on dense React DOMs with minimal overhead.\n\n*   `llama3.2:3b` - **Failed**: High hallucination rates on complex DOMs, generating fake nested layouts.\n*   `gpt-oss:20b` - **Excellent**: Flawless operation without DOM caching restrictions, but financially expensive and GPU-intensive.\n*   `qwen2.5-coder:1.5b` and `qwen2.5:3b-instruct` - **Failed**: Small models struggled with strict JSON output, often hallucinating invalid CSS syntax (e.g., `.class1(class2)`).\n*   `qwen2.5:7b` - **Optimal**: With Proactive DOM Caching and strict JSON prompt enforcement, this lightweight model achieved 100% perfect healing, offering premium intelligence at a fraction of the cost of 20B+ models.\n","readmeFilename":"README.md"}