← ClaudeAtlas

testdrivercachelisted

Speed up tests with screenshot-based caching
testdriverai/testdriverai · ★ 242 · Testing & QA · score 71
Install: claude install-skill testdriverai/testdriverai
<!-- Generated from cache.mdx. DO NOT EDIT. --> ## Overview The cache system speeds up repeated test runs by comparing screenshots to cached results. When the screen hasn't changed significantly, cached element positions are reused instead of making an AI call. Cache works at two levels: - **Screen cache** — pixel diff comparison between the current screenshot and the cached screenshot - **Element cache** — OpenCV template matching to verify the cached element position is still correct ## How It Works 1. On `find()`, the SDK sends the current screenshot and cache metadata to the API 2. The API compares the screenshot against previously cached results for the same `cacheKey` 3. If the screen pixel diff is within the `screen` threshold AND the element template match exceeds the `element` threshold, the cached position is returned 4. Otherwise, a new AI call is made and the result is cached ```mermaid flowchart LR A[Screenshot + cacheKey] --> B{Screen Diff\n< threshold?} B -- Yes --> C{Template\nMatch OK?} C -- Yes --> D[Return cached position] B -- No --> E[AI Call - fresh] C -- No --> F[AI Call - fresh] ``` ## Configuration ### Constructor Options ```javascript const testdriver = new TestDriver({ cache: { enabled: true, thresholds: { find: { screen: 0.05, // 5% pixel diff allowed (default) element: 0.8, // 80% OpenCV correlation required (default) }, assert: 0.05, // 5% pixel diff for assert